From 6e24b78b6289be365f6ae9e35baed1dbf5e16353 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 17 Sep 2015 23:27:34 +0800 Subject: [PATCH] fix the wrong response --- error.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/error.go b/error.go index 60f2098c..ff060c4d 100644 --- a/error.go +++ b/error.go @@ -390,18 +390,18 @@ func ErrorController(c ControllerInterface) *App { // show error string as simple text message. // if error string is empty, show 503 or 500 error as default. func exception(errCode string, ctx *context.Context) { + code, _ := strconv.Atoi(errCode) + if code == 0 { + code = 503 + } for _, ec := range []string{errCode, "503", "500"} { - code, _ := strconv.Atoi(errCode) - if code == 0 { - code = 503 - } if h, ok := ErrorMaps[ec]; ok { executeError(h, ctx, code) return } } //if 50x error has been removed from errorMap - ctx.ResponseWriter.WriteHeader(503) + ctx.ResponseWriter.WriteHeader(code) ctx.WriteString(errCode) }