1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 12:00:55 +00:00
This commit is contained in:
astaxie 2013-12-13 21:25:25 +08:00
parent 9c164408d3
commit 495033b977

View File

@ -369,12 +369,8 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
if _, ok := err.(middleware.HTTPException); ok { if _, ok := err.(middleware.HTTPException); ok {
// catch intented errors, only for HTTP 4XX and 5XX // catch intented errors, only for HTTP 4XX and 5XX
} else { } else {
if ErrorsShow { if RunMode == "dev" {
handler := p.getErrorHandler(fmt.Sprint(err))
handler(rw, r)
} else {
if !RecoverPanic { if !RecoverPanic {
// go back to panic
panic(err) panic(err)
} else { } else {
var stack string var stack string
@ -385,15 +381,30 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
break break
} }
Critical(file, line) Critical(file, line)
if RunMode == "dev" { stack = stack + fmt.Sprintln(file, line)
stack = stack + fmt.Sprintln(file, line)
}
} }
if RunMode == "dev" { middleware.ShowErr(err, rw, r, stack)
middleware.ShowErr(err, rw, r, stack) }
} else {
if ErrorsShow {
handler := p.getErrorHandler(fmt.Sprint(err))
handler(rw, r)
} else {
if !RecoverPanic {
panic(err)
} else {
Critical("Handler crashed with error", err)
for i := 1; ; i++ {
_, file, line, ok := runtime.Caller(i)
if !ok {
break
}
Critical(file, line)
}
} }
} }
} }
} }
} }
}() }()