@@ -2,6 +2,7 @@ package maxminddb
22
33import (
44 "encoding/binary"
5+ "fmt"
56 "math"
67 "math/big"
78 "reflect"
@@ -418,7 +419,7 @@ func (d *decoder) unmarshalMap(
418419 result = indirect (result )
419420 switch result .Kind () {
420421 default :
421- return 0 , newUnmarshalTypeError ("map" , result .Type ())
422+ return 0 , newUnmarshalTypeStrError ("map" , result .Type ())
422423 case reflect .Struct :
423424 return d .decodeStruct (size , offset , result , depth )
424425 case reflect .Map :
@@ -430,7 +431,7 @@ func (d *decoder) unmarshalMap(
430431 result .Set (rv )
431432 return newOffset , err
432433 }
433- return 0 , newUnmarshalTypeError ("map" , result .Type ())
434+ return 0 , newUnmarshalTypeStrError ("map" , result .Type ())
434435 }
435436}
436437
@@ -465,7 +466,7 @@ func (d *decoder) unmarshalSlice(
465466 return newOffset , err
466467 }
467468 }
468- return 0 , newUnmarshalTypeError ("array" , result .Type ())
469+ return 0 , newUnmarshalTypeStrError ("array" , result .Type ())
469470}
470471
471472func (d * decoder ) unmarshalString (size , offset uint , result reflect.Value ) (uint , error ) {
@@ -615,7 +616,7 @@ func (d *decoder) decodeMap(
615616
616617 offset , err = d .decode (offset , elemValue , depth )
617618 if err != nil {
618- return 0 , err
619+ return 0 , fmt . Errorf ( "decoding value for %s: %w" , key , err )
619620 }
620621
621622 keyValue .SetString (string (key ))
@@ -772,7 +773,7 @@ func (d *decoder) decodeStruct(
772773
773774 offset , err = d .decode (offset , result .Field (j ), depth )
774775 if err != nil {
775- return 0 , err
776+ return 0 , fmt . Errorf ( "decoding value for %s: %w" , key , err )
776777 }
777778 }
778779 return offset , nil
0 commit comments