DoError logs the error and responds with the given status code with a generic status text
(w http.ResponseWriter, msg string, err error, statusCode int)
| 71 | |
| 72 | // DoError logs the error and responds with the given status code with a generic status text |
| 73 | func DoError(w http.ResponseWriter, msg string, err error, statusCode int) { |
| 74 | var message string |
| 75 | if err == nil { |
| 76 | message = msg |
| 77 | } else { |
| 78 | message = errors.Wrap(err, msg).Error() |
| 79 | } |
| 80 | |
| 81 | log.WithFields(log.Fields{ |
| 82 | "statusCode": statusCode, |
| 83 | }).Error(message) |
| 84 | |
| 85 | statusText := http.StatusText(statusCode) |
| 86 | http.Error(w, statusText, statusCode) |
| 87 | } |
| 88 | |
| 89 | // NotSupported is the handler for the route that is no longer supported |
| 90 | func NotSupported(w http.ResponseWriter, r *http.Request) { |
no test coverage detected