summaryrefslogtreecommitdiffstats
path: root/modules/context
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-07-26 02:48:17 +0800
committerUnknwon <u@gogs.io>2016-07-26 02:48:17 +0800
commit899e7994595f5fc500de8cdf39e1b737f9f00982 (patch)
tree1477940293968f1ee2781e04209b7038e9774d95 /modules/context
parent2295fafb34e2467f3b380a4db8832aa2c70ecc5a (diff)
downloadgitea-899e7994595f5fc500de8cdf39e1b737f9f00982.tar.gz
gitea-899e7994595f5fc500de8cdf39e1b737f9f00982.zip
#1601 support delete issue comment
Diffstat (limited to 'modules/context')
-rw-r--r--modules/context/context.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index 6ca7e574f6..971d075d0f 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -105,6 +105,19 @@ 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) {
+ if errck(err) {
+ ctx.Error(status, err.Error())
+ return
+ }
+
+ ctx.Handle(500, title, err)
+}
+
func (ctx *Context) HandleText(status int, title string) {
if (status/100 == 4) || (status/100 == 5) {
log.Error(4, "%s", title)