MCPcopy Create free account
hub / github.com/kataras/iris / StopWithError

Method StopWithError

context/context.go:809–824  ·  view source on GitHub ↗

StopWithError stops the handlers chain and writes the "statusCode" among with the error "err". It Calls the `SetErr` method so error handlers can access the given error. If the status code is a failure one then it will also fire the specified error code handler. If the given "err" is private then

(statusCode int, err error)

Source from the content-addressed store, hash-verified

807// If the given "err" is private then the
808// status code's text is rendered instead (unless a registered error handler overrides it).
809func (ctx *Context) StopWithError(statusCode int, err error) {
810 if err == nil {
811 return
812 }
813
814 ctx.SetErr(err)
815 if _, ok := err.(ErrPrivate); ok {
816 // error is private, we SHOULD not render it,
817 // leave the error handler alone to
818 // render the code's text instead.
819 ctx.StopWithStatus(statusCode)
820 return
821 }
822
823 ctx.StopWithText(statusCode, err.Error())
824}
825
826// StopWithPlainError like `StopWithError` but it does NOT
827// write anything to the response writer, it stores the error

Callers 15

ViewMethod · 0.95
RenderMethod · 0.95
ValidateMethod · 0.80
NewAppFunction · 0.80
mainFunction · 0.80
BeginAuthHandlerFunction · 0.80
mainFunction · 0.80
CreateTodoFunction · 0.80
GetTodoFunction · 0.80
ListTodosFunction · 0.80
ListAllTodosFunction · 0.80
SignInFunction · 0.80

Calls 4

SetErrMethod · 0.95
StopWithStatusMethod · 0.95
StopWithTextMethod · 0.95
ErrorMethod · 0.65

Tested by 5

TestJWTFunction · 0.64
HandleErrorMethod · 0.64
TestPayloadBindingFunction · 0.64
HandleErrorMethod · 0.64
HandleErrorMethod · 0.64