Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more informative message when setting inexistant config items
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 17 Aug 2019 22:42:48 +0000 (00:42 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 17 Aug 2019 23:34:16 +0000 (01:34 +0200)
src/xbt/config.cpp

index c50e805..e51a1ba 100644 (file)
@@ -307,7 +307,10 @@ inline ConfigurationElement* Config::get_dict_element(const std::string& name)
         XBT_INFO("Option %s has been renamed to %s. Consider switching.", name.c_str(), res->get_key().c_str());
       return res;
     } else {
-      throw std::out_of_range("Bad config key: " + name);
+      std::string msg = "Bad config key: " + name + "\nExisting config keys:\n";
+      for (auto const& elm : options)
+        msg += "  " + elm.first + ": (" + elm.second->get_type_name() + ")" + elm.second->get_string_value() + "\n";
+      throw std::out_of_range(msg);
     }
   }
 }