Skip to content

Commit

Permalink
change err
Browse files Browse the repository at this point in the history
  • Loading branch information
cadyrov committed Oct 30, 2020
1 parent 8bfa951 commit 2ae43c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ func ValidateStruct(structPtr interface{}, fields ...*FieldRules) goerr.IError {
if ft.Anonymous {
// merge errors from anonymous struct field
if es, ok := err.(verror.ErrStack); ok {
for name, value := range es.Stack {
errs.Stack[name] = value
for name, value := range es.Details {
errs.Details[name] = value
}
continue
}
}
errs.Stack[getErrorFieldName(ft)] = err
errs.Details[getErrorFieldName(ft)] = err
}
}

if len(errs.Stack) > 0 {
if len(errs.Details) > 0 {
return errs
}
return nil
Expand Down
6 changes: 3 additions & 3 deletions verror/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ var mpErr map[int]string = map[int]string{
}

type ErrStack struct {
Details map[string]goerr.IError `json:"details"`
Error goerr.IError `json:"error"`
Details map[string]goerr.IError `json:"details"`
goerr.IError `json:"error"`
}

func NewErrStack(message string) ErrStack {
mp := make(map[string]goerr.IError)
e := goerr.New(message)
return ErrStack{
Details: mp,
Error: e,
IError: e,
}
}

Expand Down

0 comments on commit 2ae43c0

Please sign in to comment.