Skip to content

Commit 51356a3

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 d0e165b commit 51356a3

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
@@ -103,8 +103,7 @@ PATH:
103103
case string:
104104
// We are expecting a map
105105
if typeNum != KindMap {
106-
// XXX - use type names in errors.
107-
return fmt.Errorf("expected a map for %s but found %d", v, typeNum)
106+
return fmt.Errorf("expected a map for %s but found %s", v, typeNum.String())
108107
}
109108
for range size {
110109
var key []byte
@@ -125,8 +124,7 @@ PATH:
125124
case int:
126125
// We are expecting an array
127126
if typeNum != KindSlice {
128-
// XXX - use type names in errors.
129-
return fmt.Errorf("expected a slice for %d but found %d", v, typeNum)
127+
return fmt.Errorf("expected a slice for %d but found %s", v, typeNum.String())
130128
}
131129
var i uint
132130
if v < 0 {

0 commit comments

Comments
 (0)