Skip to content

Commit

Permalink
default exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
JessonChan committed Sep 18, 2015
1 parent 4823a0f commit ead635e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,18 +390,19 @@ 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(ec)
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(code)
//set 503 as default
ctx.ResponseWriter.WriteHeader(503)
ctx.WriteString(errCode)
}

Expand Down

0 comments on commit ead635e

Please sign in to comment.