mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-02 07:00:38 +08:00
better config check & error message
This commit is contained in:
parent
fa0ea6e0b5
commit
53bd39d80e
@ -437,10 +437,15 @@ double ConfigBase::get_abs_value(const t_config_option_key &opt_key) const
|
||||
{
|
||||
// Get stored option value.
|
||||
const ConfigOption *raw_opt = this->option(opt_key);
|
||||
assert(raw_opt != nullptr);
|
||||
if (raw_opt == nullptr) {
|
||||
std::stringstream ss; ss << "You can't define an option that need " << opt_key << " without defining it!";
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
if (raw_opt->type() == coFloat)
|
||||
return static_cast<const ConfigOptionFloat*>(raw_opt)->value;
|
||||
if (raw_opt->type() == coFloatOrPercent) {
|
||||
if(!static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->percent)
|
||||
return static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->value;
|
||||
// Get option definition.
|
||||
const ConfigDef *def = this->def();
|
||||
if (def == nullptr)
|
||||
@ -453,7 +458,8 @@ double ConfigBase::get_abs_value(const t_config_option_key &opt_key) const
|
||||
return opt_def->ratio_over.empty() ? 0. :
|
||||
static_cast<const ConfigOptionFloatOrPercent*>(raw_opt)->get_abs_value(this->get_abs_value(opt_def->ratio_over));
|
||||
}
|
||||
throw std::runtime_error("ConfigBase::get_abs_value(): Not a valid option type for get_abs_value()");
|
||||
std::stringstream ss; ss << "ConfigBase::get_abs_value(): "<< opt_key<<" has not a valid option type for get_abs_value()";
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
|
||||
// Return an absolute value of a possibly relative config variable.
|
||||
|
Loading…
x
Reference in New Issue
Block a user