mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
chore: refactor mapping errors (#3843)
This commit is contained in:
parent
0441f84606
commit
7822a4c1cb
@ -250,8 +250,9 @@ func (u *Unmarshaler) fillSliceFromString(fieldType reflect.Type, value reflect.
|
|||||||
func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int,
|
func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int,
|
||||||
baseKind reflect.Kind, value any, fullName string) error {
|
baseKind reflect.Kind, value any, fullName string) error {
|
||||||
if value == nil {
|
if value == nil {
|
||||||
return errUnsupportedType
|
return errNilSliceElement
|
||||||
}
|
}
|
||||||
|
|
||||||
ithVal := slice.Index(index)
|
ithVal := slice.Index(index)
|
||||||
switch v := value.(type) {
|
switch v := value.(type) {
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
|
@ -1340,7 +1340,7 @@ func TestUnmarshalNullableSlice(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ast := assert.New(t)
|
ast := assert.New(t)
|
||||||
ast.Equal(UnmarshalKey(m, &v), errUnsupportedType)
|
ast.Equal(UnmarshalKey(m, &v), errNilSliceElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnmarshalIntSlice(t *testing.T) {
|
func TestUnmarshalIntSlice(t *testing.T) {
|
||||||
|
@ -36,6 +36,7 @@ const (
|
|||||||
var (
|
var (
|
||||||
errUnsupportedType = errors.New("unsupported type on setting field value")
|
errUnsupportedType = errors.New("unsupported type on setting field value")
|
||||||
errNumberRange = errors.New("wrong number range setting")
|
errNumberRange = errors.New("wrong number range setting")
|
||||||
|
errNilSliceElement = errors.New("null element for slice")
|
||||||
optionsCache = make(map[string]optionsCacheValue)
|
optionsCache = make(map[string]optionsCacheValue)
|
||||||
cacheLock sync.RWMutex
|
cacheLock sync.RWMutex
|
||||||
structRequiredCache = make(map[reflect.Type]requiredCacheValue)
|
structRequiredCache = make(map[reflect.Type]requiredCacheValue)
|
||||||
|
Loading…
Reference in New Issue
Block a user