2fas-server/internal/common/recovery/recovery.go

21 lines
313 B
Go
Raw Normal View History

2023-04-11 23:39:25 +02:00
package recovery
import (
"github.com/twofas/2fas-server/internal/common/logging"
)
func DoNotPanic(fn func()) {
defer func() {
if err := recover(); err != nil {
stack := stack(3)
logging.WithFields(logging.Fields{
"stack": string(stack),
"error": err,
}).Error("Panic")
}
}()
fn()
}