aboutsummaryrefslogtreecommitdiff
path: root/hotline/panic.go
diff options
context:
space:
mode:
Diffstat (limited to 'hotline/panic.go')
-rw-r--r--hotline/panic.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/hotline/panic.go b/hotline/panic.go
new file mode 100644
index 0000000..e7c97db
--- /dev/null
+++ b/hotline/panic.go
@@ -0,0 +1,15 @@
+package hotline
+
+import (
+ "fmt"
+ "go.uber.org/zap"
+ "runtime/debug"
+)
+
+// dontPanic logs panics instead of crashing
+func dontPanic(logger *zap.SugaredLogger) {
+ if r := recover(); r != nil {
+ fmt.Println("stacktrace from panic: \n" + string(debug.Stack()))
+ logger.Errorw("PANIC", "err", r, "trace", string(debug.Stack()))
+ }
+}