errors.Join
docs are terse on how to inspect joined errors. My initial approach, upon reading the following passage
// A non-nil error returned by Join implements the Unwrap() []error method.
was to do something like this:
if joined, ok := err.(interface{ Unwrap() []error }); ok {
for _, err := range joined.Unwrap() {
...
}
}
Only by reading the docs for errors.Is
and errors.As
I realized that they can deal with "joined" errors. Let's consider adding a passage to errors.Join
such as:
// Joined errors can be inspected through Is and As.
Comment From: gabyhelp
Related Issues
- errors: improve the godoc for Join and Unwrap #59301 (closed)
- errors: add example around unwrapping errors.Join #69586 (closed)
- proposal: rework of errors.Join() #74371 (closed)
- proposal: errors: unwarap joinError to avoid deeply-nested joins #65676 (closed)
- proposal: errors: add Errors function to undo Join #57358 (closed)
- errors: Using `errors.Join` on a `joinError` should expand the existing joined error #60209 (closed)
- errors: errors.Join does not skip nil error interface implementations #70626 (closed)
- errors: unwrap joinError to avoid deeply-nested joins #65360 (closed)
Related Code Changes
Related Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)