Skip to content

Commit

Permalink
fix: wrap errors returned by JSON unmarshal
Browse files Browse the repository at this point in the history
Currently `%v` is used inside an `Errorf` call, this means the original errors is lost and cannot be unwrapped to. 

By changing it to `%w` the error is preserved and can be retrieved with `errors.As`.
  • Loading branch information
ThatsMrTalbot authored Feb 6, 2024
1 parent c3772b5 commit 8cfabdc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func jsonUnmarshal(reader io.Reader, obj interface{}, opts ...JSONOpt) error {
d = opt(d)
}
if err := d.Decode(&obj); err != nil {
return fmt.Errorf("while decoding JSON: %v", err)
return fmt.Errorf("while decoding JSON: %w", err)
}
return nil
}
Expand Down

0 comments on commit 8cfabdc

Please sign in to comment.