Skip to content
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

Print causes when outputting error stacks #41

Open
hypesystem opened this issue Jun 9, 2022 · 1 comment
Open

Print causes when outputting error stacks #41

hypesystem opened this issue Jun 9, 2022 · 1 comment

Comments

@hypesystem
Copy link

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 😄

@hypesystem
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants