mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 11:57:02 +00:00
replace all common error responses with the new Context.StopWithError
Former-commit-id: 99b08a0b5564ef640456db12674cb37721f73ae3
This commit is contained in:
@@ -19,8 +19,8 @@ func main() {
|
||||
|
||||
app.Get("/", func(ctx iris.Context) {
|
||||
if err := ctx.View("form.html"); err != nil {
|
||||
ctx.StatusCode(iris.StatusInternalServerError)
|
||||
ctx.WriteString(err.Error())
|
||||
ctx.StopWithError(iris.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
@@ -28,8 +28,8 @@ func main() {
|
||||
visitor := Visitor{}
|
||||
err := ctx.ReadForm(&visitor)
|
||||
if err != nil && !iris.IsErrPath(err) /* see: https://github.com/kataras/iris/issues/1157 */ {
|
||||
ctx.StatusCode(iris.StatusInternalServerError)
|
||||
ctx.WriteString(err.Error())
|
||||
ctx.StopWithError(iris.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Writef("Visitor: %#v", visitor)
|
||||
|
||||
Reference in New Issue
Block a user