diff options
Diffstat (limited to 'modules/context/context.go')
-rw-r--r-- | modules/context/context.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/modules/context/context.go b/modules/context/context.go index a9a5e270..e90d5f00 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -89,22 +89,24 @@ func (ctx *Context) RenderWithErr(msg string, tpl base.TplName, form interface{} // Handle handles and logs error by given status. func (ctx *Context) Handle(status int, title string, err error) { - if err != nil { - log.Error(4, "%s: %v", title, err) - if macaron.Env != macaron.PROD { - ctx.Data["ErrorMsg"] = err - } - } - switch status { case 404: ctx.Data["Title"] = "Page Not Found" case 500: ctx.Data["Title"] = "Internal Server Error" + log.Error(4, "%s: %v", title, err) + if !setting.ProdMode || (ctx.IsSigned && ctx.User.IsAdmin) { + ctx.Data["ErrorMsg"] = err + } } ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status))) } +// NotFound simply renders the 404 page. +func (ctx *Context) NotFound() { + ctx.Handle(404, "", nil) +} + // NotFoundOrServerError use error check function to determine if the error // is about not found. It responses with 404 status code for not found error, // or error context description for logging purpose of 500 server error. |