diff options
author | Haru <haru@dotalux.com> | 2016-08-20 18:15:19 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-20 19:44:56 +0300 |
commit | fd534587c716017a6614ff4499229d0bfda1891b (patch) | |
tree | f7e82f646e2a8883c2931d15f20e9eea0b65d60a | |
parent | c6cc76169db0b54247536c6ce19d376be3b49593 (diff) | |
download | hercules-fd534587c716017a6614ff4499229d0bfda1891b.tar.gz hercules-fd534587c716017a6614ff4499229d0bfda1891b.tar.bz2 hercules-fd534587c716017a6614ff4499229d0bfda1891b.tar.xz hercules-fd534587c716017a6614ff4499229d0bfda1891b.zip |
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 <haru@dotalux.com>
-rw-r--r-- | src/common/conf.c | 5 |
1 files changed, 5 insertions, 0 deletions
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 <libconfig/libconfig.h> @@ -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)); |