Fail will send the status code, write the error's reason and return the HTTPError for further use, i.e logging, see `InternalServerError`.
(ctx iris.Context, statusCode int, err error, format string, args ...interface{})
| 93 | // Fail will send the status code, write the error's reason |
| 94 | // and return the HTTPError for further use, i.e logging, see `InternalServerError`. |
| 95 | func Fail(ctx iris.Context, statusCode int, err error, format string, args ...interface{}) HTTPError { |
| 96 | httpErr := newError(statusCode, err, format, args...) |
| 97 | httpErr.writeHeaders(ctx) |
| 98 | |
| 99 | ctx.WriteString(httpErr.Description) |
| 100 | return httpErr |
| 101 | } |
| 102 | |
| 103 | // FailJSON will send to the client the error data as JSON. |
| 104 | // Useful for APIs. |
no test coverage detected
searching dependent graphs…