Skip to content

errors: Join docs should mention Is/As #74461

Open
@ikonst

Description

@ikonst

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions