Skip to content

Commit

Permalink
fixup panic catching in http handler funcs
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jeromy <[email protected]>


This commit was moved from ipfs/kubo@8ad1141
  • Loading branch information
whyrusleeping committed Dec 28, 2015
1 parent 6822c20 commit 1c8fcd9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gateway/core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"net/http"
gopath "path"
"runtime/debug"
"strings"
"time"

Expand Down Expand Up @@ -55,6 +56,14 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) {

// TODO(btc): break this apart into separate handlers using a more expressive muxer
func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer func() {
if r := recover(); r != nil {
log.Error("A panic occurred in the gateway handler!")
log.Error(r)
debug.PrintStack()
}
}()

if i.config.Writable {
switch r.Method {
case "POST":
Expand Down

0 comments on commit 1c8fcd9

Please sign in to comment.