From f77278551b125da51b6917c53e608abdecdd146c Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 20 Aug 2016 18:15:19 +0200 Subject: Added a better error message when a libconfig file is not found Previously, it'd say "[Error] (null):0 - file I/O error" Signed-off-by: Haru --- src/common/conf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/conf.c b/src/common/conf.c index 25f1013f5..9188affa4 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -24,6 +24,7 @@ #include "common/showmsg.h" // ShowError #include "common/strlib.h" // safestrncpy +#include "common/utils.h" // exists #include @@ -46,6 +47,10 @@ struct libconfig_interface *libconfig; int config_load_file(struct config_t *config, const char *config_filename) { libconfig->init(config); + if (!exists(config_filename)) { + ShowError("Unable to load '%s' - File not found\n", config_filename); + return CONFIG_FALSE; + } if (libconfig->read_file_src(config, config_filename) != CONFIG_TRUE) { ShowError("%s:%d - %s\n", config_error_file(config), config_error_line(config), config_error_text(config)); -- cgit v1.2.3-60-g2f50