diff options
author | Unknown <joe2010xtmf@163.com> | 2014-05-01 18:53:41 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-05-01 18:53:41 -0400 |
commit | 100cd181bcc9fc46981cc2a4b88c05ad459fbc8f (patch) | |
tree | 2b2a8f07fa2760721e9418c39c51d751618ada5a /modules/middleware/context.go | |
parent | 03c2468c2fa68e5b3c5cb6c498a155e7d725ccdb (diff) | |
download | gitea-100cd181bcc9fc46981cc2a4b88c05ad459fbc8f.tar.gz gitea-100cd181bcc9fc46981cc2a4b88c05ad459fbc8f.zip |
Add router log config option
Diffstat (limited to 'modules/middleware/context.go')
-rw-r--r-- | modules/middleware/context.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 1330172fde..31fdca681a 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -106,11 +106,19 @@ func (ctx *Context) RenderWithErr(msg, tpl string, form auth.Form) { // Handle handles and logs error by given status. func (ctx *Context) Handle(status int, title string, err error) { - log.Error("%s: %v", title, err) - if martini.Dev != martini.Prod { - ctx.Data["ErrorMsg"] = err + if err != nil { + log.Error("%s: %v", title, err) + if martini.Dev != martini.Prod { + ctx.Data["ErrorMsg"] = err + } } + switch status { + case 404: + ctx.Data["Title"] = "Page Not Found" + case 500: + ctx.Data["Title"] = "Internal Server Error" + } ctx.HTML(status, fmt.Sprintf("status/%d", status)) } |