Merge pull request #4797 from flycash/fix4782

fxi4782: must set status before rendering error page
This commit is contained in:
Ming Deng 2021-10-20 20:50:01 +08:00 committed by GitHub
commit 99d26b06b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -68,6 +68,8 @@
- Fix 4674: Tx Orm missing debug log [4756](https://github.com/beego/beego/pull/4756) - Fix 4674: Tx Orm missing debug log [4756](https://github.com/beego/beego/pull/4756)
- Fix 4759: fix numeric notation of permissions [4759](https://github.com/beego/beego/pull/4759) - Fix 4759: fix numeric notation of permissions [4759](https://github.com/beego/beego/pull/4759)
- set default rate and capacity for ratelimit filter [4796](https://github.com/beego/beego/pull/4796) - set default rate and capacity for ratelimit filter [4796](https://github.com/beego/beego/pull/4796)
- Fix 4782: must set status before rendering error page [4797](https://github.com/beego/beego/pull/4797)
## Fix Sonar ## Fix Sonar
- [4677](https://github.com/beego/beego/pull/4677) - [4677](https://github.com/beego/beego/pull/4677)

View File

@ -507,14 +507,16 @@ func defaultRecoverPanic(ctx *context.Context, cfg *Config) {
logs.Critical(fmt.Sprintf("%s:%d", file, line)) logs.Critical(fmt.Sprintf("%s:%d", file, line))
stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d", file, line)) stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d", file, line))
} }
if cfg.RunMode == DEV && cfg.EnableErrorsRender {
showErr(err, ctx, stack)
}
if ctx.Output.Status != 0 { if ctx.Output.Status != 0 {
ctx.ResponseWriter.WriteHeader(ctx.Output.Status) ctx.ResponseWriter.WriteHeader(ctx.Output.Status)
} else { } else {
ctx.ResponseWriter.WriteHeader(500) ctx.ResponseWriter.WriteHeader(500)
} }
if cfg.RunMode == DEV && cfg.EnableErrorsRender {
showErr(err, ctx, stack)
}
} }
} }