Skip to content

Commit

Permalink
feat: error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Myllaume committed Dec 1, 2024
1 parent f96f7f3 commit dc1a9ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
4 changes: 2 additions & 2 deletions core/models/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand Down

0 comments on commit dc1a9ca

Please sign in to comment.