ServeJSONError sends a JSON error response to rw for the provided error value.
(rw http.ResponseWriter, err interface{})
| 256 | // ServeJSONError sends a JSON error response to rw for the provided |
| 257 | // error value. |
| 258 | func ServeJSONError(rw http.ResponseWriter, err interface{}) { |
| 259 | code := 500 |
| 260 | if i, ok := err.(httpCoder); ok { |
| 261 | code = i.HTTPCode() |
| 262 | } |
| 263 | msg := fmt.Sprint(err) |
| 264 | log.Printf("Sending error %v to client for: %v", code, msg) |
| 265 | ReturnJSONCode(rw, code, map[string]interface{}{ |
| 266 | "error": msg, |
| 267 | "errorType": http.StatusText(code), |
| 268 | }) |
| 269 | } |
| 270 | |
| 271 | // DecodeJSON decodes the JSON in res.Body into dest and then closes |
| 272 | // res.Body. |
no test coverage detected