]> git.r.bdr.sh - rbdr/mobius/blame - hotline/panic.go
Update documentation
[rbdr/mobius] / hotline / panic.go
CommitLineData
a9bdccb7
JH
1package hotline
2
3import (
4 "fmt"
a6216dd8 5 "log/slog"
a9bdccb7
JH
6 "runtime/debug"
7)
8
9// dontPanic logs panics instead of crashing
a6216dd8 10func dontPanic(logger *slog.Logger) {
a9bdccb7
JH
11 if r := recover(); r != nil {
12 fmt.Println("stacktrace from panic: \n" + string(debug.Stack()))
a6216dd8 13 logger.Error("PANIC", "err", r, "trace", string(debug.Stack()))
a9bdccb7
JH
14 }
15}