-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 Feature: Add support for outputting Error cause #2735
Comments
any news on this feature? |
current workaround: mocha -r setup.js // setup.js
const VError = require('verror')
process.on('uncaughtException', error => {
console.error(VError.fullStack(error))
})
process.on('unhandledRejection', error => {
console.error(VError.fullStack(error))
}) This isn't ideal however, because we report the error twice. Once from
|
Here's an old PR implementing this: #2381 |
This can work if you're willing to use a custom reporter. See https://github.com/unscrambl/mocha-custom-stack-trace-reporter/blob/8c23026d7bc5aef823a0011e3f575b61e039e2c8/src/mochaCustomStackTraceReporter.ts for example. The custom reporter can simply register a |
Per #4829, retargeting this to indicate support for |
We are using VError to gather up nested traces which is something proving to be very useful with promises and generators (we can actually get complete stack traces that way). However the default reporting with Mocha only outputs the first error in the stack.
For example, with this code:
You get the output:
This doesn't actually tell me where the root error came from (in
function2
)If I add a try...catch and then
console.error(e)
the top level error, I got a lot more detail:Of course, this is incredibly verbose but I would prefer this over less. I suspect this is because of the features that have been implemented that clean up the stack traces. I don't see why those couldn't run recursively and clean up all the nested stacks and output something more like this:
Now I can see the original exception in
function2
.The text was updated successfully, but these errors were encountered: