Skip to content

Commit 9f1fad1

Browse files
committed
fix: print error when internal cli error happens
There have been issues where the reported error is "ERROR: null", which is very unhelpful. Here is an analysis of a specific example: #5048 (comment) Although the trigger for that error was fixed by #5074, the unhelpfulness of "ERROR: null" was not addressed. To help with debugging, this patch prints the original error when this stage is unexpectedly reached.
1 parent 9cc3ada commit 9f1fad1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/cli/cli.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => {
6666
debug("caught error sometime before command handler: %O", err);
6767
yargs.showHelp();
6868
console.error(`\n${symbols.error} ${pc.red("ERROR:")} ${msg}`);
69+
if (!msg) {
70+
// Log raw error and stack when an unexpected error is encountered, to
71+
// make debugging easier (instead of an inactionable "ERROR: null").
72+
console.error(err);
73+
}
6974
process.exit(1);
7075
})
7176
.help("help", "Show usage information & exit")

0 commit comments

Comments
 (0)