@@ -2,6 +2,7 @@ package maxminddb
2
2
3
3
import (
4
4
"encoding/binary"
5
+ "fmt"
5
6
"math"
6
7
"math/big"
7
8
"reflect"
@@ -418,7 +419,7 @@ func (d *decoder) unmarshalMap(
418
419
result = indirect (result )
419
420
switch result .Kind () {
420
421
default :
421
- return 0 , newUnmarshalTypeError ("map" , result .Type ())
422
+ return 0 , newUnmarshalTypeStrError ("map" , result .Type ())
422
423
case reflect .Struct :
423
424
return d .decodeStruct (size , offset , result , depth )
424
425
case reflect .Map :
@@ -430,7 +431,7 @@ func (d *decoder) unmarshalMap(
430
431
result .Set (rv )
431
432
return newOffset , err
432
433
}
433
- return 0 , newUnmarshalTypeError ("map" , result .Type ())
434
+ return 0 , newUnmarshalTypeStrError ("map" , result .Type ())
434
435
}
435
436
}
436
437
@@ -465,7 +466,7 @@ func (d *decoder) unmarshalSlice(
465
466
return newOffset , err
466
467
}
467
468
}
468
- return 0 , newUnmarshalTypeError ("array" , result .Type ())
469
+ return 0 , newUnmarshalTypeStrError ("array" , result .Type ())
469
470
}
470
471
471
472
func (d * decoder ) unmarshalString (size , offset uint , result reflect.Value ) (uint , error ) {
@@ -615,7 +616,7 @@ func (d *decoder) decodeMap(
615
616
616
617
offset , err = d .decode (offset , elemValue , depth )
617
618
if err != nil {
618
- return 0 , err
619
+ return 0 , fmt . Errorf ( "decoding value for %s: %w" , key , err )
619
620
}
620
621
621
622
keyValue .SetString (string (key ))
@@ -772,7 +773,7 @@ func (d *decoder) decodeStruct(
772
773
773
774
offset , err = d .decode (offset , result .Field (j ), depth )
774
775
if err != nil {
775
- return 0 , err
776
+ return 0 , fmt . Errorf ( "decoding value for %s: %w" , key , err )
776
777
}
777
778
}
778
779
return offset , nil
0 commit comments