From 11977f4f77a94a858e26d1badb53b82a2fecb622 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sun, 7 Jul 2013 17:58:50 +0800 Subject: [PATCH] fix #90 --- beego.go | 2 ++ config.go | 3 +++ router.go | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/beego.go b/beego.go index f19b7202..5a638d88 100644 --- a/beego.go +++ b/beego.go @@ -43,6 +43,7 @@ var ( DirectoryIndex bool //ebable DirectoryIndex default is false EnbaleHotUpdate bool //enable HotUpdate default is false HttpServerTimeOut int64 + ErrorsShow bool ) func init() { @@ -70,6 +71,7 @@ func init() { StaticDir["/static"] = "static" AppConfigPath = path.Join(AppPath, "conf", "app.conf") HttpServerTimeOut = 0 + ErrorsShow = true ParseConfig() } diff --git a/config.go b/config.go index 752204a2..6aebbc2a 100644 --- a/config.go +++ b/config.go @@ -183,6 +183,9 @@ func ParseConfig() (err error) { if timeout, err := AppConfig.Int64("httpservertimeout"); err == nil { HttpServerTimeOut = timeout } + if errorsshow, err := AppConfig.Bool("errorsshow"); err == nil { + ErrorsShow = errorsshow + } } return nil } diff --git a/router.go b/router.go index 02a6b01c..cbdbb7d8 100644 --- a/router.go +++ b/router.go @@ -189,7 +189,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) defer func() { if err := recover(); err != nil { errstr := fmt.Sprint(err) - if handler, ok := ErrorMaps[errstr]; ok { + if handler, ok := ErrorMaps[errstr]; ok && ErrorsShow { handler(rw, r) } else { if !RecoverPanic {