Caporal.js
Caporal.js copied to clipboard
Hidden stack trace when an error occurs
Describe the bug When an error is raised in my application, the error is printed in white, and the stack trace is not shown. For example, only this message is printed and the application exits right after:
The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
To Reproduce Steps to reproduce the behavior:
// place this line anywhere in a Caporal app
throw new Error('test')
Expected behavior I expect to have a red error message with the original stack trace so I can debug my code without headache.
Environment informations (please complete the following information):
- OS: OSX
- OS version: Catalina
- Shell: zsh
- Caporal version: 1.4.0
Looks like this was added in https://github.com/mattallty/Caporal.js/pull/168, but isn't available in 2.0.2. I'd love to see stack traces with --verbose
, as well.
For now, I desperate add this .catch()
:
program.run().catch((err) => {
console.log("ERR:", err);
});
Perhaps I'm just not familiar with how it works, but seems that --verbose
already has a meaning. It changes the how the logger is configured.
So perhaps it would make more sense to add a --debug
flag that is built in. Its meaning can be to unhide stack traces.
There is no --debug
flag built-in. You should indeed use --verbose
to display stack traces.
The idea is for developers to provide to their users clean error messages without raw stack traces. (that could still be seen in verbose mode).