[NOD-416] Use errors.Is and add goroutine stack trace to HandlePanic (#459)

* [NOD-416] Use errors.Is and add goroutine stack trace to HandlePanic

* [NOD-416] Don't print goroutineStackTrace if it's nil
This commit is contained in:
Ori Newman
2019-11-13 11:20:20 +02:00
committed by Dan Aharoni
parent 83bad65d3a
commit a7f08598f3
13 changed files with 30 additions and 22 deletions

View File

@@ -1,7 +1,6 @@
package httpserverutils
import (
"fmt"
"github.com/pkg/errors"
"net/http"
"runtime/debug"
@@ -45,8 +44,7 @@ func RecoveryMiddleware(h http.Handler) http.Handler {
} else {
recoveryErrAsError = errors.Errorf("%s", recoveryErr)
}
recoveryErrStr := fmt.Sprintf("%s", recoveryErr)
log.Criticalf("Fatal error: %+v", recoveryErrStr)
log.Criticalf("Fatal error: %+v", recoveryErrAsError)
log.Criticalf("Stack trace: %s", debug.Stack())
SendErr(ctx, w, recoveryErrAsError)
}