From 1146a9b90bc9c12e331b6338aeec267e7df5beed Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 26 Mar 2015 22:52:27 -0600 Subject: [PATCH] Recover from panic during requests --- server/server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/server.go b/server/server.go index b5e3f1663..d416e0ae5 100644 --- a/server/server.go +++ b/server/server.go @@ -101,6 +101,11 @@ func (s *Server) Serve() error { // ServeHTTP is the entry point for each request to s. func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { + defer func() { + if rec := recover(); rec != nil { + log.Printf("[PANIC] '%s': %s", r.URL.String(), rec) + } + }() s.stack(w, r) }