1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 18:10:54 +00:00

fix the wrong response

This commit is contained in:
astaxie 2015-09-17 23:27:34 +08:00
parent bb6062857b
commit 6e24b78b62

View File

@ -390,18 +390,18 @@ func ErrorController(c ControllerInterface) *App {
// show error string as simple text message. // show error string as simple text message.
// if error string is empty, show 503 or 500 error as default. // if error string is empty, show 503 or 500 error as default.
func exception(errCode string, ctx *context.Context) { func exception(errCode string, ctx *context.Context) {
code, _ := strconv.Atoi(errCode)
if code == 0 {
code = 503
}
for _, ec := range []string{errCode, "503", "500"} { for _, ec := range []string{errCode, "503", "500"} {
code, _ := strconv.Atoi(errCode)
if code == 0 {
code = 503
}
if h, ok := ErrorMaps[ec]; ok { if h, ok := ErrorMaps[ec]; ok {
executeError(h, ctx, code) executeError(h, ctx, code)
return return
} }
} }
//if 50x error has been removed from errorMap //if 50x error has been removed from errorMap
ctx.ResponseWriter.WriteHeader(503) ctx.ResponseWriter.WriteHeader(code)
ctx.WriteString(errCode) ctx.WriteString(errCode)
} }