refactor: improve error handling
dwmkerr opened this issue · 0 comments
dwmkerr commented
Might be easier to just do:
console.error('An error occurred labelling the icon: ${err}');
Another improvement would be to perhaps standardise the error logging a little, to make sure we print in colour, using chalk
, and perhaps even only show the internal error message if a verbose flag like -v
is set - but this can happen later.
It also means we could potentially simplify things with something like:
function errorAndExit(errorMessage, internalError, verbose, exitCode) {
console.error(`${chalk.red('error')}: ${errorMessage}`);
if (verbose) {
console.error(`${chalk.red('internal error')}: ${(internalError || '').toString()}`);
}
process.exit(exitCode);
}
Also really I should document in the README
what the error codes are and actually use separate error codes for separate conditions, but that's an improvement for another time.