1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-23 21:07:03 +00:00

👔 next version: some linting

Former-commit-id: a102fbb90e2a8a8b09fcb9c9e0c370e4078b74d1
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-03-01 08:34:53 +02:00
parent 2756435446
commit 1c9b592088
9 changed files with 82 additions and 107 deletions

View File

@@ -8,12 +8,19 @@ import (
)
type (
// ErrorHandler describes an interface to handle errors per hero handler and its dependencies.
//
// Handles non-nil errors return from a hero handler or a controller's method (see `getBindingsFor` and `Handler`)
// the error may return from a request-scoped dependency too (see `Handler`).
ErrorHandler interface {
HandleError(context.Context, error)
}
// ErrorHandlerFunc implements the `ErrorHandler`.
// It describes the type defnition for an error function handler.
ErrorHandlerFunc func(context.Context, error)
)
// HandleError fires when a non-nil error returns from a request-scoped dependency at serve-time or the handler itself.
func (fn ErrorHandlerFunc) HandleError(ctx context.Context, err error) {
fn(ctx, err)
}
@@ -41,7 +48,7 @@ var (
ctx.StatusCode(DefaultErrStatusCode)
}
ctx.WriteString(err.Error())
_, _ = ctx.WriteString(err.Error())
}
ctx.StopExecution()