tank/code/core/handler.go
2019-05-04 23:36:05 +08:00

21 lines
316 B
Go

package core
//run a method with panic recovery.
func RunWithRecovery(f func()) {
defer func() {
if err := recover(); err != nil {
LOGGER.Error("error in async method: %v", err)
}
}()
//execute the method
f()
}
//shortcut for panic check
func PanicError(err error) {
if err != nil {
panic(err)
}
}