standard/gosafe/recovery.go
2026-03-28 19:31:44 +08:00

23 lines
313 B
Go

package gosafe
import (
"context"
"runtime/debug"
"gitea.micah.com/micah/standard/pkg/log"
)
// Recovery .
func Recovery(ctx context.Context) {
e := recover()
if e == nil {
return
}
if ctx == nil {
ctx = context.Background()
}
log.Errorf("catch panic err=%v\nstacktrace=%s", e, debug.Stack())
}