MCPcopy
hub / github.com/koderover/zadig / ErrorMessage

Function ErrorMessage

pkg/tool/errors/errors.go:128–151  ·  view source on GitHub ↗

ErrorMessage returns the code and message for Gins JSON helpers

(err error)

Source from the content-addressed store, hash-verified

126
127// ErrorMessage returns the code and message for Gins JSON helpers
128func ErrorMessage(err error) (code int, message map[string]interface{}) {
129 v, ok := err.(*HTTPError)
130 if ok {
131 code = v.Code()
132 // FIXME: change this logic
133 if v.Code()/1000 == 6 || v.Code()/1000 == 7 {
134 code = ErrInvalidParam.Code()
135 }
136 return code, map[string]interface{}{
137 "type": "error",
138 "message": v.Message(),
139 "code": v.Code(),
140 "description": v.Desc(),
141 "extra": v.Extra(),
142 }
143 }
144
145 internalErr := NewHTTPError(500, "Internal Error")
146 return internalErr.Code(), map[string]interface{}{
147 "message": internalErr.Error(),
148 "code": internalErr.Code(),
149 "description": err.Error(),
150 }
151}

Callers 1

TestErrorsFunction · 0.70

Calls 8

CodeMethod · 0.95
ErrorMethod · 0.95
NewHTTPErrorFunction · 0.85
CodeMethod · 0.65
MessageMethod · 0.65
DescMethod · 0.65
ExtraMethod · 0.65
ErrorMethod · 0.65

Tested by 1

TestErrorsFunction · 0.56