go-zero/core/rescue/recover.go
Kevin Wan fdc57d07d7
fix: #2672 (#2681)
* fix: #2672

* chore: fix more cases

* chore: update deps

* chore: update deps

* chore: refactor

* chore: refactor

* chore: refactor
2022-12-11 00:41:50 +08:00

18 lines
311 B
Go

package rescue
import "github.com/zeromicro/go-zero/core/logx"
// Recover is used with defer to do cleanup on panics.
// Use it like:
//
// defer Recover(func() {})
func Recover(cleanups ...func()) {
for _, cleanup := range cleanups {
cleanup()
}
if p := recover(); p != nil {
logx.ErrorStack(p)
}
}