mirror of
https://github.com/balena-io/etcher.git
synced 2025-11-09 02:18:31 +00:00
fix(CLI): don't print stack traces by default (#1206)
Currently, the Etcher CLI will print scary stack traces for every single error (e.g: if you forgot to pass an image to the tool), given that `errors.getDescription()` will return a stack trace if no other description could be found. This commit introduces an `ETCHER_CLI_DEBUG` environment variable, which when set, it will cause the Etcher CLI to output stack traces, plus a boolean `userFriendlyDescriptionsOnly` option to `errors.getDescription()`, so we can control whether `errors.getDescription()` returns things like stack traces, or stringified error objects. Change-Type: minor Changelog-Entry: Don't print stack traces by default in the CLI. Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit is contained in:
@@ -31,10 +31,17 @@ const errors = require('../shared/errors');
|
||||
*/
|
||||
exports.printError = (error) => {
|
||||
const title = errors.getTitle(error);
|
||||
const description = errors.getDescription(error);
|
||||
const description = errors.getDescription(error, {
|
||||
userFriendlyDescriptionsOnly: true
|
||||
});
|
||||
|
||||
console.error(chalk.red(title));
|
||||
|
||||
if (description) {
|
||||
console.error(`\n${chalk.red(description)}`);
|
||||
}
|
||||
|
||||
if (process.env.ETCHER_CLI_DEBUG && error.stack) {
|
||||
console.error(`\n${chalk.red(error.stack)}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user