From 428c2ec0e35492ef218862e432afb0e6ceed68c6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 17 Jul 2018 22:08:08 +0200 Subject: test/read_conf: throw if setting is not configured --- test/read_conf.cxx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/read_conf.cxx b/test/read_conf.cxx index 4fc52a842..e2b290b72 100644 --- a/test/read_conf.cxx +++ b/test/read_conf.cxx @@ -47,17 +47,12 @@ try { ReadConfigFile(config_path); const char *value = config_get_string(option); - int ret; - if (value != NULL) { - printf("%s\n", value); - ret = EXIT_SUCCESS; - } else { - fprintf(stderr, "No such setting: %s\n", name); - ret = EXIT_FAILURE; - } + if (value == nullptr) + throw FormatRuntimeError("No such setting: %s", name); + printf("%s\n", value); config_global_finish(); - return ret; + return EXIT_SUCCESS; } catch (...) { PrintException(std::current_exception()); return EXIT_FAILURE; -- cgit v1.2.3