MCPcopy Index your code
hub / github.com/gourouting/singo / ErrorResponse

Function ErrorResponse

api/main.go:33–49  ·  view source on GitHub ↗

ErrorResponse returns an error message.

(err error)

Source from the content-addressed store, hash-verified

31
32// ErrorResponse returns an error message.
33func ErrorResponse(err error) serializer.Response {
34 if ve, ok := err.(validator.ValidationErrors); ok {
35 for _, e := range ve {
36 field := conf.T(fmt.Sprintf("Field.%s", e.Field()))
37 tag := conf.T(fmt.Sprintf("Tag.Valid.%s", e.Tag()))
38 return serializer.ParamErr(
39 fmt.Sprintf("%s%s", field, tag),
40 err,
41 )
42 }
43 }
44 if _, ok := err.(*json.UnmarshalTypeError); ok {
45 return serializer.ParamErr("JSON type mismatch", err)
46 }
47
48 return serializer.ParamErr("Parameter error", err)
49}

Callers 2

UserRegisterFunction · 0.85
UserLoginFunction · 0.85

Calls 2

TFunction · 0.92
ParamErrFunction · 0.92

Tested by

no test coverage detected