You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tree output format should be opt-in, and we should default to just empty-line-separated leaf errors.
For leaf errors, multi-error parent just provides an additional piece of the error trace, so there will be some repetition of frames between those errors.
This also ties into #71: we can expose a simple iterator func(error, []frame) with the understanding that parent/child relationships don't need to be exposed.
So here's my thinking:
Tree representation is not actually useful.
Nobody wants an ASCII error representation in their error output.
They either want structured information (which is now possible with #102),
or they want simple readable output.
I propose that we change Format and FormatString to do empty-line-separated errors for multi-errors.
So the trace for a single error chain is:
The above case looks better if we don't print the multi-error itself (which makes sense since we're traversing its children), but it loses information if there was a trace leading up to the multi-error.
Activity
prashantv commentedon Dec 12, 2023
+1 on formatting customization options.
I'd also like to experiment with an option to deduplicate the error messages in the tree for common uses of
errors.Join.abhinav commentedon May 4, 2024
So here's my thinking:
Tree representation is not actually useful.
Nobody wants an ASCII error representation in their error output.
They either want structured information (which is now possible with #102),
or they want simple readable output.
I propose that we change Format and FormatString to do empty-line-separated errors for multi-errors.
So the trace for a single error chain is:
And the trace for a multi-error is:
This matches the simplicity of
errors.Join, which does newline-separated messages.Anything more customizable can be done with
UnwrapFramedirectly.If anyone actually finds the tree functionality useful, we can put it in a FormatTree function.
Thoughts?
Edit: Update:
Tried it out. The output doesn't look good if we also print the multi-error.
You end up with:
The above case looks better if we don't print the multi-error itself (which makes sense since we're traversing its children), but it loses information if there was a trace leading up to the multi-error.
abhinav commentedon May 4, 2024
Example from playing around:
Flat:
Tree: