diff --git a/app.js b/app.js index 16efde0..4ef93cf 100755 --- a/app.js +++ b/app.js @@ -193,3 +193,12 @@ function setConfigFileToRun(projectName) { Config.configFilePath = Config.defaultConfigPath; } } + +process.on('uncaughtException', (err) => { + console.error(['\x1b[31m', 'Err.', '\x1b[0m'].join(''), err.message); + process.exit(1); +}); +process.on('unhandledRejection', (err) => { + console.error(['\x1b[31m', 'Err.', '\x1b[0m'].join(''), err.message); + process.exit(1); +}); diff --git a/core/models/config.js b/core/models/config.js index f0e03d3..afca775 100644 --- a/core/models/config.js +++ b/core/models/config.js @@ -367,7 +367,7 @@ class Config { static get(configFilePath) { if (configFilePath === undefined || fs.existsSync(configFilePath) === false) { - throw new Error('Can not find config file.'); + throw new Error(`Can not find config file from ${configFilePath}.`); } const fileContent = fs.readFileSync(configFilePath, 'utf8'); @@ -390,7 +390,7 @@ class Config { .flatMap((detail) => [detail.message, detail.context.message]) .join(', '); - throw new Error(`Config schema validation failed: ${details}`); + throw new Error(`Config file ${configFilePath} contains errors :\n${details}`); } return new Config(opts);