Chromium Code Reviews| Index: server/middleware/paniccatcher.go |
| diff --git a/server/middleware/paniccatcher.go b/server/middleware/paniccatcher.go |
| index 15486b234de6eccf6f9fb9065be765e7ebe7bfc9..e9dd41e503fbae82debdd3debc6bbc7c8b01aa26 100644 |
| --- a/server/middleware/paniccatcher.go |
| +++ b/server/middleware/paniccatcher.go |
| @@ -7,26 +7,23 @@ package middleware |
| import ( |
| "net/http" |
| - "github.com/julienschmidt/httprouter" |
| - "golang.org/x/net/context" |
| - |
| log "github.com/luci/luci-go/common/logging" |
| "github.com/luci/luci-go/common/paniccatcher" |
| + "github.com/luci/luci-go/server/router" |
| ) |
| // WithPanicCatcher is a middleware that catches panics, dumps stack trace to |
| // logging and returns HTTP 500. |
| -func WithPanicCatcher(h Handler) Handler { |
| - return func(c context.Context, w http.ResponseWriter, r *http.Request, p httprouter.Params) { |
| +func WithPanicCatcher() router.Handler { |
| + return func(c *router.Context) { |
| defer paniccatcher.Catch(func(p *paniccatcher.Panic) { |
| log.Fields{ |
| "panic.error": p.Reason, |
| - }.Errorf(c, "Caught panic during handling of %q:\n%s", r.RequestURI, p.Stack) |
| + }.Errorf(c.Context, "Caught panic during handling of %q:\n%s", c.Request.RequestURI, p.Stack) |
| // Note: it may be too late to send HTTP 500 if `h` already sent |
| // headers. But there's nothing else we can do at this point anyway. |
| - http.Error(w, "Internal Server Error. See logs.", http.StatusInternalServerError) |
| + http.Error(c.Writer, "Internal Server Error. See logs.", http.StatusInternalServerError) |
| }) |
| - h(c, w, r, p) |
| } |
|
iannucci
2016/06/13 19:23:29
does this still work? I don't think this works any
|
| } |