From 02357d26164864f014e09b81306a5f259da24d17 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sat, 22 Apr 2023 13:03:59 +0800 Subject: [PATCH] chore: make error message more readable (#3154) --- core/mapping/unmarshaler.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/mapping/unmarshaler.go b/core/mapping/unmarshaler.go index ff36556d..1e1c4eb9 100644 --- a/core/mapping/unmarshaler.go +++ b/core/mapping/unmarshaler.go @@ -881,9 +881,11 @@ func (u *Unmarshaler) unmarshalWithFullName(m valuerWithParent, v any, fullName typeField := baseType.Field(i) valueField := valElem.Field(i) if err := u.processField(typeField, valueField, m, fullName); err != nil { - if fullName != "" { - err = fmt.Errorf("%s, fullName :%s, typeField :%s, valueField :%s", err.Error(), fullName, typeField.Name, valueField.Type()) + if len(fullName) > 0 { + err = fmt.Errorf("%w, fullName: %s, field: %s, type: %s", + err, fullName, typeField.Name, valueField.Type().Name()) } + return err } }