Skip to content

Commit 7022686

Browse files
authored
Update decode.go with a more robust error message
1 parent 37d0612 commit 7022686

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

decode.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ func unmarshal(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error {
3838
if err != nil {
3939
return err
4040
}
41-
if dec == nil {
42-
return errors.New("go-json: CompileToGetDecoder returned a nil decoder")
43-
}
41+
if err == nil && dec == nil {
42+
return fmt.Errorf(
43+
"go-json: CompileToGetDecoder returned a nil decoder for type %s",
44+
header.typ.String(),
45+
)
46+
}
4447
ctx := decoder.TakeRuntimeContext()
4548
ctx.Buf = src
4649
ctx.Option.Flags = 0

0 commit comments

Comments
 (0)