Don't silently fail to start up if a config file is invalid

Originally committed to SVN as r5535.
This commit is contained in:
Thomas Goyne 2011-08-17 05:32:09 +00:00
parent 330411c94a
commit 0c1794a93f

View file

@ -59,9 +59,17 @@ json::UnknownElement file(const std::string &file) {
json::UnknownElement file(const std::string &file, const std::string &default_config) {
try {
return parse(io::Open(file));
// We only want to catch this single error as anything else could
// reflect a deeper problem. ie, failed i/o, wrong permissions etc.
} catch (const acs::AcsNotFound&) {
}
catch (const acs::AcsNotFound&) {
// Not an error
return parse(new std::istringstream(default_config));
}
catch (json::Exception&) {
// Already logged in parse
return parse(new std::istringstream(default_config));
}
catch (agi::Exception& e) {
LOG_E("json/file") << "Unexpted error when reading config file " << file << ": " << e.GetMessage();
return parse(new std::istringstream(default_config));
}
}