ENH: start normally when deal with unknown enumeration value

Change-Id: Ibc3d47a6181528e3aa747d79ae2a436f548f05f1
(cherry picked from commit 7fc01b6f1aea831b41d5a63b3d8858de12572b65)
This commit is contained in:
zhimin.zeng 2022-11-28 09:47:19 +08:00 committed by Lane.Wei
parent 7dddb17d8a
commit 284154d053
2 changed files with 3 additions and 3 deletions

View File

@ -615,7 +615,7 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con
if (! success && substitutions_ctxt.rule != ForwardCompatibilitySubstitutionRule::Disable &&
// Only allow substitutions of an enum value by another enum value or a boolean value with an enum value.
// That means, we expect enum values being added in the future and possibly booleans being converted to enums.
(optdef->type == coEnum || optdef->type == coBool) && ConfigHelpers::looks_like_enum_value(value)) {
(optdef->type == coEnum || optdef->type == coEnums || optdef->type == coBool) /*&& ConfigHelpers::looks_like_enum_value(value)*/) {
// Deserialize failed, try to substitute with a default value.
//assert(substitutions_ctxt.rule == ForwardCompatibilitySubstitutionRule::Enable || substitutions_ctxt.rule == ForwardCompatibilitySubstitutionRule::EnableSilent);
if (optdef->type == coBool)

View File

@ -1701,12 +1701,12 @@ public:
while (std::getline(is, item_str, ',')) {
boost::trim(item_str);
if (item_str == "nil") {
throw ConfigurationError("Deserializing nil into a non-nullable object");
return false;
}
else {
auto it = this->keys_map->find(item_str);
if (it == this->keys_map->end())
throw ConfigurationError(std::string("Unknown enum type: ") + item_str);
return false;
this->values.push_back(it->second);
}
}