8000 fix: wrap errors returned by JSON unmarshal · kubernetes-sigs/yaml@4c6913f · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c6913f

Browse files
ThatsMrTalbotAdam Talbot
authored andcommitted
fix: wrap errors returned by JSON unmarshal
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`.
1 parent 56d6720 commit 4c6913f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

yaml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func jsonUnmarshal(reader io.Reader, obj interface{}, opts ...JSONOpt) error {
9292
d = opt(d)
9393
}
9494
if err := d.Decode(&obj); err != nil {
95-
return fmt.Errorf("while decoding JSON: %v", err)
95+
return fmt.Errorf("while decoding JSON: %w", err)
9696
}
9797
return nil
9898
}

0 commit comments

Comments
 (0)
0