finalhandler
finalhandler copied to clipboard
Print causes when outputting error stacks
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:

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:
Just to clarify: I am very willing to do a PR for this, if it is within scope of this package :smile: