1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-12 00:21:01 +00:00

add error show page

This commit is contained in:
astaxie
2013-04-11 14:35:43 +08:00
parent ddc3d7d58c
commit f4a645027e
2 changed files with 79 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package beego
import (
"fmt"
"net/http"
"net/url"
"reflect"
@ -190,13 +191,20 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
// go back to panic
panic(err)
} else {
var stack string
Critical("Handler crashed with error", err)
for i := 1; ; i += 1 {
for i := 1; ; i++ {
_, file, line, ok := runtime.Caller(i)
if !ok {
break
}
Critical(file, line)
if RunMode == "dev" {
stack = stack + fmt.Sprintln(file, line)
}
}
if RunMode == "dev" {
ShowErr(err, rw, r, stack)
}
}
}