Skip to content

Commit

Permalink
logid: Fail on invalid Configurations
Browse files Browse the repository at this point in the history
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.

NixOS/nixpkgs#167388
  • Loading branch information
ckiee committed Jan 2, 2023
1 parent 85e0c46 commit 1096680
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/logid/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/logid/logid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 1096680

Please sign in to comment.