-
-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Problem
We recently-ish added the Exception object so that messages like test step failures can express an exception in a structured way.
One pattern this doesn't allow for is nested exceptions. It's fairly common for an exception to wrap another exception, and is standardised as "cause" in at least Java and JavaScript.
Formatters should ideally be able to surface structured nested exceptions - users don't want to lose that important information, or have to parse it out of a big stack trace. Since formatters should now be implemented in terms of messages, that means adding it to the schema.
Proposal
Add an optional cause
field to the Exception
object, the value of which is another Exception
. This should be a non-breaking change for consumers.
Considerations
The obvious concern here is circularity. Implementers should be urged to avoid this in a similar way to the JSON.stringify
algorithm, where on seeing the same exception a second time in the same tree we set it to null and break. We should also consider a limit on the level of nesting e.g. 10 as a hard circuit breaker.