logid: Fail on invalid Configurations

NixOS will soon have a runtime test for logiops which uses an
invalid configuration as a baseline, expecting it to fail.

Silent errors are not nice for users; systemd does not inform users
of stderr messages in nominally running services.

https://github.com/NixOS/nixpkgs/pull/167388
This commit is contained in:
ckie 2022-12-10 23:33:37 +02:00
parent dbe2b28a53
commit 5741a9a323
No known key found for this signature in database
GPG Key ID: 13E79449C0525215
2 changed files with 4 additions and 3 deletions

View File

@ -34,11 +34,11 @@ Configuration::Configuration(const std::string& config_file)
} catch(const FileIOException &e) {
logPrintf(ERROR, "I/O Error while reading %s: %s", config_file.c_str(),
e.what());
throw e;
exit(EXIT_FAILURE);
} catch(const ParseException &e) {
logPrintf(ERROR, "Parse error in %s, line %d: %s", e.getFile(),
e.getLine(), e.getError());
throw e;
exit(EXIT_FAILURE);
}
const Setting &root = _config.getRoot();

View File

@ -168,7 +168,8 @@ int main(int argc, char** argv)
global_config = std::make_shared<Configuration>(options.config_file);
}
catch (std::exception &e) {
global_config = std::make_shared<Configuration>();
logPrintf(ERROR, "%s", e.what());
return EXIT_FAILURE;
}
global_workqueue = std::make_shared<workqueue>(
global_config->workerCount());