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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user