aboutsummaryrefslogtreecommitdiff
path: root/hotline/panic.go
blob: e7c97dbe1fa4502af81de2efb624742b3d02cb10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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()))
	}
}