cockroachdb / cockroachdb/errors

Errors returned from Join are incompatible with errors returned the standard lib's errors.Join

Offen
#162 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
2.5k
Forks
74
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

The standard errors package uses the following example to extract the individual sub-errors from the result err of calling Join:

https://pkg.go.dev/errors#Join
`fmt.Println(err.(interface{ Unwrap() []error }).Unwrap())`

This is not possible with return values of Join:
`panic: interface conversion: *withstack.withStack is not interface { Unwrap() []error }: missing method Unwrap`

However the code needed to do the same is, unintuitively:
`fmt.Println(err.(interface{ Unwrap() error }).Unwrap().(interface{ Unwrap() []error }).Unwrap())`

Or is there a better way do it?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.