Skip to content

Commit

Permalink
Wrap errors (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahParks authored Jan 11, 2024
1 parent d272c92 commit 5bad29e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions keyfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ func NewJWKJSON(raw json.RawMessage) (Keyfunc, error) {
}
jwk, err := jwkset.NewJWKFromRawJSON(raw, marshalOptions, jwkset.JWKValidateOptions{})
if err != nil {
return nil, fmt.Errorf("%w: could not create JWK from raw JSON", ErrKeyfunc)
return nil, fmt.Errorf("%w: could not create JWK from raw JSON", errors.Join(err, ErrKeyfunc))
}
store := jwkset.NewMemoryStorage()
err = store.KeyWrite(context.Background(), jwk)
if err != nil {
return nil, fmt.Errorf("%w: could not write JWK to storage", ErrKeyfunc)
return nil, fmt.Errorf("%w: could not write JWK to storage", errors.Join(err, ErrKeyfunc))
}
options := Options{
Storage: store,
Expand All @@ -92,11 +92,11 @@ func NewJWKSetJSON(raw json.RawMessage) (Keyfunc, error) {
var jwks jwkset.JWKSMarshal
err := json.Unmarshal(raw, &jwks)
if err != nil {
return nil, fmt.Errorf("%w: could not unmarshal raw JWK Set JSON", ErrKeyfunc)
return nil, fmt.Errorf("%w: could not unmarshal raw JWK Set JSON", errors.Join(err, ErrKeyfunc))
}
store, err := jwks.ToStorage()
if err != nil {
return nil, fmt.Errorf("%w: could not create JWK Set storage", ErrKeyfunc)
return nil, fmt.Errorf("%w: could not create JWK Set storage", errors.Join(err, ErrKeyfunc))
}
options := Options{
Storage: store,
Expand Down

0 comments on commit 5bad29e

Please sign in to comment.