Skip to content

Commit f448c0d

Browse files
committed
Improved error message
1 parent fbc88e6 commit f448c0d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

go-configmap/configuration.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ func tryConversion(current any, desiredType reflect.Type) (any, error) {
9494
}
9595
return currentArray, nil
9696
}
97-
return nil, fmt.Errorf("invalid conversion, got %T but want %v", current, desiredType)
97+
98+
currentTypeString := currentType.String()
99+
if currentTypeString == "[]interface {}" {
100+
currentTypeString = "array"
101+
}
102+
return nil, fmt.Errorf("invalid conversion, got %s but want %v", currentTypeString, desiredType)
98103
}
99104

100105
func (c Map) set(keys []string, value any) {

0 commit comments

Comments
 (0)