From fd1a31afb6d320be08fe1338caebd31000449d3e Mon Sep 17 00:00:00 2001 From: sese Date: Fri, 5 Aug 2016 19:18:31 +0200 Subject: [PATCH] More precise error messages in case configuration couldn't be loaded. --- js/app.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index 1ffbafb8..14f10e8b 100644 --- a/js/app.js +++ b/js/app.js @@ -41,8 +41,16 @@ var App = function() { var config = Object.assign(defaults, c); callback(config); } catch (e) { - console.error("WARNING! Could not find config. Please create one."); - callback(defaults); + if (e.code == "ENOENT") { + console.error("WARNING! Could not find config file. Please create one. Starting with default configuration."); + callback(defaults); + } else if (e instanceof ReferenceError || e instanceof SyntaxError) { + console.error("WARNING! Could not validate config file. Please correct syntax errors. Starting with default configuration."); + callback(defaults); + } else { + console.error("WARNING! Could not load config file. Starting with default configuration. Error found: " + e); + callback(defaults); + } } };