1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-26 13:25:56 +00:00
Former-commit-id: 55589069c8ed458183d28f32870fdf8f233629c6
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-07-11 16:14:31 +03:00
parent 3574816e1d
commit c8ed26ee51
8 changed files with 981 additions and 923 deletions

View File

@@ -114,14 +114,23 @@ type compatibleErr interface {
Error() string
}
// dispatchErr writes the error to the response.
// dispatchErr sets the error status code
// and the error value to the context.
// The APIBuilder's On(Any)ErrorCode is responsible to render this error code.
func dispatchErr(ctx *context.Context, status int, err error) bool {
if err == nil {
return false
}
ctx.StatusCode(status)
DefaultErrorHandler.HandleError(ctx, err)
if err != ErrStopExecution {
if status == 0 || !context.StatusCodeNotSuccessful(status) {
status = DefaultErrStatusCode
}
ctx.StatusCode(status)
}
ctx.SetErr(err)
return true
}