MCPcopy
hub / github.com/uber/aresdb / RespondWithError

Function RespondWithError

api/common/response.go:107–122  ·  view source on GitHub ↗

RespondWithError responds with error.

(w http.ResponseWriter, err error)

Source from the content-addressed store, hash-verified

105
106// RespondWithError responds with error.
107func RespondWithError(w http.ResponseWriter, err error) {
108 var errorResponse ErrorResponse
109 if e, ok := err.(utils.APIError); ok {
110 errorResponse = ErrorResponse{
111 Body: e,
112 }
113 } else {
114 errorResponse = ErrorResponse{
115 Body: utils.APIError{
116 Code: http.StatusInternalServerError,
117 Message: err.Error(),
118 },
119 }
120 }
121 RespondJSONObjectWithCode(w, errorResponse.Body.Code, errorResponse.Body)
122}
123
124// RespondWithBadRequest responds with StatusBadRequest as code.
125func RespondWithBadRequest(w http.ResponseWriter, err error) {

Callers 2

writeJSONBytesFunction · 0.85
RespondWithBadRequestFunction · 0.85

Calls 2

ErrorMethod · 0.65

Tested by

no test coverage detected