Open magicmark opened 5 years ago
This would be super useful as we've found tools like stackdriver / new relic group errors based on the stacktrace meaning it incorrectly groups different errors which happen to be caught, wrapped and rethrown at the same place.
I think as long as that's an option that's off by default and any potential downsides are documented clearly, that seems reasonable! As I recall, V8 avoids formatting stack traces until they're explicitly requested via an access to the stack
property because it's fairly expensive and many errors never wind up having their stack formatted. Is it possible to implement what you suggested and preserve that behavior?
Thanks for this awesome library, excited to use it!
Motivation:
Let's say I want to catch something and rethrow it with my own error message and context. Something like this:
We lose the full context of the error in the default output when throwing. My motivation in using this library is to preserve the previous errors in the stack.
I can can use
VError.fullStack
, but it's not clear how to throw an error that prints the full stack trace.tl;dr
Output:
Prior Art
Looks like others are experimenting with this too? https://github.com/duccio/winston-verror-format/blob/f7adb35552a4de7b092540b683d0ec5a08ea5c28/src/index.ts#L22
Suggestion
Would you be open to a PR that provides a new option -
useFullStack
that kinda does the above? So I could do something like this:Thanks!