Replaced throwing strings with exception objects. Fixes #3433

This commit is contained in:
Joseph Lenox 2017-06-04 09:05:41 -05:00
parent e2b3d25edf
commit 9f0335b4b8
2 changed files with 5 additions and 5 deletions

View File

@ -256,7 +256,7 @@ ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys &opt_
for (const t_config_option_key &opt_key : opt_keys) {
ConfigOption* my_opt = this->option(opt_key, true);
if (my_opt == NULL) {
if (ignore_nonexistent == false) throw "Attempt to apply non-existent option";
if (ignore_nonexistent == false) throw UnknownOptionException();
continue;
}
@ -339,7 +339,7 @@ ConfigBase::get_abs_value(const t_config_option_key &opt_key) const {
} else if (const ConfigOptionFloat* optv = dynamic_cast<const ConfigOptionFloat*>(opt)) {
return optv->value;
} else {
throw "Not a valid option type for get_abs_value()";
throw std::runtime_error("Not a valid option type for get_abs_value()");
}
}
@ -487,7 +487,7 @@ DynamicConfig::optptr(const t_config_option_key &opt_key, bool create) {
optv->keys_map = &optdef->enum_keys_map;
opt = static_cast<ConfigOption*>(optv);
} else {
throw "Unknown option type";
throw std::runtime_error("Unknown option type");
}
this->options[opt_key] = opt;
return opt;

View File

@ -349,8 +349,8 @@ Model::duplicate_objects(size_t copies_num, coordf_t dist, const BoundingBoxf* b
void
Model::duplicate_objects_grid(size_t x, size_t y, coordf_t dist)
{
if (this->objects.size() > 1) throw "Grid duplication is not supported with multiple objects";
if (this->objects.empty()) throw "No objects!";
if (this->objects.size() > 1) throw std::runtime_error("Grid duplication is not supported with multiple objects");
if (this->objects.empty()) throw std::runtime_error("No objects!");
ModelObject* object = this->objects.front();
object->clear_instances();