Closed Silic0nS0ldier closed 2 years ago
I'm not really sure what you mean by a standard way to extend stack traces. Error objects already can have an AggregateError, where you can provide anything you like in the errors
array.
Either way, this is beyond the scope of this proposal - this proposal's sole and entire goal is to specify the current behavior of browsers, while providing robust static methods to access this data. This kind of idea would need to wait for a follow-on proposal, after this one has advanced.
There are occasions where stack traces fail to pinpoint the error source (e.g.
Error
being constructed on a unique code path, rethrowing ofError
instances). It would be useful if a standard way to augment a stack trace with additional context was available.A standard here may aid error monitoring tools (e.g. Sentry) which attempt to parse the stack trace to provide a richer debug experience.
Scenarios
Error
being constructed on a unique code pathtrace-unhandled
can be used to address this issue during development (it is stated as not being for production use). It produces stack traces similar to the following.The stack trace differs considerably from the normal stack.
Rethrowing of
Error
instancesNo sample necessary for this scenario. The stack trace will simply not include the rethrow site. There is some overlap with #41 here, perhaps mainly with how the trace should be extended.