Caporal.js icon indicating copy to clipboard operation
Caporal.js copied to clipboard

Hidden stack trace when an error occurs

Open pyrsmk opened this issue 4 years ago • 3 comments

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

pyrsmk avatar Jun 15 '20 08:06 pyrsmk

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.

donmccurdy avatar Nov 16 '20 01:11 donmccurdy

For now, I desperate add this .catch():

program.run().catch((err) => {
  console.log("ERR:", err);
});

peterbe avatar Apr 27 '22 19:04 peterbe

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.

peterbe avatar Apr 28 '22 12:04 peterbe

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).

mattallty avatar Aug 28 '23 11:08 mattallty