From 780cc2d11093e048e41f2d6da9d76f6c6ac4a5e2 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 30 Aug 2016 02:08:38 -0700 Subject: router/repo: code refactoring --- modules/context/context.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'modules/context/context.go') diff --git a/modules/context/context.go b/modules/context/context.go index 971d075d..ac46bb38 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -105,13 +105,12 @@ func (ctx *Context) Handle(status int, title string, err error) { ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status))) } -// HandleError use error check function to determine if server should -// response as client input error or server internal error. -// It responses with given status code for client error, -// or error context description for logging purpose of server error. -func (ctx *Context) HandleError(title string, errck func(error) bool, err error, status int) { +// 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. +func (ctx *Context) NotFoundOrServerError(title string, errck func(error) bool, err error) { if errck(err) { - ctx.Error(status, err.Error()) + ctx.Handle(404, title, err) return } -- cgit v1.2.3