Fixes CustomAbort

Always set the response status in the CustomAbort function
This commit is contained in:
lowitea 2021-07-01 16:28:36 +03:00 committed by GitHub
parent 61f5ce8c6c
commit 1378006d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -411,9 +411,9 @@ func (c *Controller) Abort(code string) {
// CustomAbort stops controller handler and show the error data, it's similar Aborts, but support status code and body.
func (c *Controller) CustomAbort(status int, body string) {
c.Ctx.Output.Status = status
// first panic from ErrorMaps, it is user defined error functions.
if _, ok := ErrorMaps[body]; ok {
c.Ctx.Output.Status = status
panic(body)
}
// last panic user string