mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
fdc57d07d7
* fix: #2672 * chore: fix more cases * chore: update deps * chore: update deps * chore: refactor * chore: refactor * chore: refactor
18 lines
311 B
Go
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)
|
|
}
|
|
}
|