mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-12 12:09:56 +01:00
21 lines
313 B
Go
21 lines
313 B
Go
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()
|
|
}
|