mirror of
https://github.com/kataras/iris.git
synced 2026-01-11 05:55:57 +00:00
add mvc.Err builtin dependency to map any context/mvc response's.Err field on methods like HandleHTTPError
relative to: https://github.com/kataras/iris/issues/1606
This commit is contained in:
@@ -168,6 +168,9 @@ var BuiltinDependencies = []*Dependency{
|
||||
NewDependency(func(ctx *context.Context) Code {
|
||||
return Code(ctx.GetStatusCode())
|
||||
}).Explicitly(),
|
||||
NewDependency(func(ctx *context.Context) Err {
|
||||
return Err(ctx.GetErr())
|
||||
}).Explicitly(),
|
||||
// payload and param bindings are dynamically allocated and declared at the end of the `binding` source file.
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,20 @@ type (
|
||||
ErrorHandlerFunc func(*context.Context, error)
|
||||
|
||||
// Code is a special type for status code.
|
||||
// It's used for a builtin dependency to map the status code given by a previous
|
||||
// method or middleware.
|
||||
// Use a type like that in order to not conflict with any developer-registered
|
||||
// dependencies.
|
||||
// Alternatively: ctx.GetStatusCode().
|
||||
Code int
|
||||
|
||||
// Err is a special type for error stored in mvc responses or context.
|
||||
// It's used for a builtin dependency to map the error given by a previous
|
||||
// method or middleware.
|
||||
// Use a type like that in order to not conflict with any developer-registered
|
||||
// dependencies.
|
||||
// Alternatively: ctx.GetErr().
|
||||
Err error
|
||||
)
|
||||
|
||||
// HandleError fires when a non-nil error returns from a request-scoped dependency at serve-time or the handler itself.
|
||||
|
||||
Reference in New Issue
Block a user