1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00

add some api helpers

This commit is contained in:
kataras
2022-05-05 02:46:15 +03:00
parent 4a43cd1fbb
commit 10c1542daf
5 changed files with 56 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
package errors
import "github.com/kataras/iris/v12/context"
// DefaultContextErrorHandler returns a context error handler
// which fires a JSON bad request (400) error message when
// a rich rest response failed to be written to the client.
// Register it on Application.SetContextErrorHandler method.
var DefaultContextErrorHandler context.ErrorHandler = new(jsonErrorHandler)
type jsonErrorHandler struct{}
// HandleContextError completes the context.ErrorHandler interface. It's fired on
// rich rest response failures.
func (e *jsonErrorHandler) HandleContextError(ctx *context.Context, err error) {
InvalidArgument.Err(ctx, err)
}