finalhandler icon indicating copy to clipboard operation
finalhandler copied to clipboard

Print causes when outputting error stacks

Open hypesystem opened this issue 3 years ago • 1 comments

In getErrorMessage, which is used to create a pretty error messages that is both logged and returned to clients in non-production environments, the error message is found by simply taking err.stack.

Errors now support the cause option (not really well-documented in Node.js documentation, but it's on MDN), which allows listing originating causes for an error (for example, if an error is thrown as the result of a different error).

err.stack does not print this, but for example browser consoles show the causes nicely:

image

Would you be interested in a PR adding the cause chain to the output of getErrorMessage? I think this would be a nice addition, and I would personally find it useful :smile:

hypesystem avatar Jun 09 '22 13:06 hypesystem

Just to clarify: I am very willing to do a PR for this, if it is within scope of this package :smile:

hypesystem avatar Jun 10 '22 09:06 hypesystem