From 3518e19811bf7e7594438354681016a0e1ed218b Mon Sep 17 00:00:00 2001 From: arielshaqed Date: Thu, 21 Apr 2022 12:37:10 +0300 Subject: [PATCH] Wrap decodehook errors when reporting Allow mapstructure caller to use `errors.Is` and `errors.As` to determine the cause of errors returned by custom decode hooks. --- mapstructure.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapstructure.go b/mapstructure.go index 1efb22ac..9ff5741f 100644 --- a/mapstructure.go +++ b/mapstructure.go @@ -458,7 +458,7 @@ func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) e var err error input, err = DecodeHookExec(d.config.DecodeHook, inputVal, outVal) if err != nil { - return fmt.Errorf("error decoding '%s': %s", name, err) + return fmt.Errorf("error decoding '%s': %w", name, err) } }