cockroachdb / cockroachdb/errors

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

Aperta
#162 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
2.5k
Fork
74
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.