Skip to content

Commit 752d9a5

Browse files
committed
Improve error messages to show type names instead of numbers
Error messages for type mismatches now display readable type names like 'Map' and 'Slice' instead of numeric codes, making debugging easier.
1 parent 77bb546 commit 752d9a5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

internal/decoder/reflection.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ PATH:
107107
case string:
108108
// We are expecting a map
109109
if typeNum != KindMap {
110-
// XXX - use type names in errors.
111-
return fmt.Errorf("expected a map for %s but found %d", v, typeNum)
110+
return fmt.Errorf("expected a map for %s but found %s", v, typeNum.String())
112111
}
113112
for range size {
114113
var key []byte
@@ -129,8 +128,7 @@ PATH:
129128
case int:
130129
// We are expecting an array
131130
if typeNum != KindSlice {
132-
// XXX - use type names in errors.
133-
return fmt.Errorf("expected a slice for %d but found %d", v, typeNum)
131+
return fmt.Errorf("expected a slice for %d but found %s", v, typeNum.String())
134132
}
135133
var i uint
136134
if v < 0 {

0 commit comments

Comments
 (0)