summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-14 01:51:12 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-14 01:51:12 -0400
commit15f8bc417e2b5683e2cd578c9c50f51acfd3daba (patch)
tree0e76575eda02bbbfc095d6620e49659cff56a2bd /modules
parent56cf05be771977abd9ae2e68dd446092c595981c (diff)
downloadgitea-15f8bc417e2b5683e2cd578c9c50f51acfd3daba.tar.gz
gitea-15f8bc417e2b5683e2cd578c9c50f51acfd3daba.zip
Add log.handle
Diffstat (limited to 'modules')
-rw-r--r--modules/log/error.go32
-rw-r--r--modules/log/log.go10
2 files changed, 10 insertions, 32 deletions
diff --git a/modules/log/error.go b/modules/log/error.go
deleted file mode 100644
index cb94ec2473..0000000000
--- a/modules/log/error.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2014 The Gogs Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package log
-
-import (
- "github.com/codegangsta/martini"
- "github.com/martini-contrib/render"
-)
-
-// ErrHandler is an interface for custom error handler.
-type ErrHandler interface {
- Handle(string, render.Render, error)
-}
-
-// ErrHandle is a Middleware that maps a ErrHandler service into the Martini handler chain.
-func ErrHandle() martini.Handler {
- return func(context martini.Context) {
- context.MapTo(&errHandler{}, (*ErrHandler)(nil))
- }
-}
-
-type errHandler struct {
-}
-
-func (eh *errHandler) Handle(title string, r render.Render, err error) {
- Error("%s: %v", title, err)
- r.HTML(200, "base/error", map[string]interface{}{
- "ErrorMsg": err,
- })
-}
diff --git a/modules/log/log.go b/modules/log/log.go
index 0634bde655..f71be7c133 100644
--- a/modules/log/log.go
+++ b/modules/log/log.go
@@ -6,7 +6,11 @@
package log
import (
+ "github.com/martini-contrib/render"
+
"github.com/gogits/logs"
+
+ "github.com/gogits/gogs/modules/base"
)
var logger *logs.BeeLogger
@@ -35,3 +39,9 @@ func Warn(format string, v ...interface{}) {
func Critical(format string, v ...interface{}) {
logger.Critical(format, v...)
}
+
+func Handle(status int, title, tmpl string, data base.TmplData, r render.Render, err error) {
+ data["ErrorMsg"] = err
+ Error("%s: %v", title, err)
+ r.HTML(status, tmpl, data)
+}