github.com/bytedance/go-tagexpr@v2.7.5-0.20210114074101-de5b8743ad85+incompatible/binding/error.go (about) 1 package binding 2 3 // Error validate error 4 type Error struct { 5 ErrType, FailField, Msg string 6 } 7 8 // Error implements error interface. 9 func (e *Error) Error() string { 10 if e.Msg != "" { 11 return e.ErrType + ": expr_path=" + e.FailField + ", cause=" + e.Msg 12 } 13 return e.ErrType + ": expr_path=" + e.FailField + ", cause=invalid" 14 } 15 16 func newDefaultErrorFactory(errType string) func(string, string) error { 17 return func(failField, msg string) error { 18 return &Error{ 19 ErrType: errType, 20 FailField: failField, 21 Msg: msg, 22 } 23 } 24 }