cockroachdb / cockroachdb/errors

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

Ouverte
#162 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Go
Étoiles
2.5k
Forks
74
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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?

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Start with the Join implementation and the withStack unwrapping behavior, then compare the result with the standard library errors.Join example linked in the issue. Confirm how callers can reach the individual sub-errors, and consider the work complete when Join results support the standard Unwrap() []error extraction pattern or the project documents the intended alternative.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
go
Domaine
backend
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
52/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.