mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 03:47:04 +00:00
replace all common error responses with the new Context.StopWithError
Former-commit-id: 99b08a0b5564ef640456db12674cb37721f73ae3
This commit is contained in:
@@ -14,8 +14,7 @@ func MyHandler(ctx iris.Context) {
|
||||
var c Company
|
||||
|
||||
if err := ctx.ReadJSON(&c); err != nil {
|
||||
ctx.StatusCode(iris.StatusBadRequest)
|
||||
ctx.WriteString(err.Error())
|
||||
ctx.StopWithError(iris.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -33,8 +32,7 @@ func MyHandler2(ctx iris.Context) {
|
||||
var persons []Person
|
||||
err := ctx.ReadJSON(&persons)
|
||||
if err != nil {
|
||||
ctx.StatusCode(iris.StatusBadRequest)
|
||||
ctx.WriteString(err.Error())
|
||||
ctx.StopWithError(iris.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user