You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
287 B
18 lines
287 B
|
7 years ago
|
package util
|
||
|
7 years ago
|
|
||
|
|
|
||
|
|
//带有panic恢复的方法
|
||
|
|
func PanicHandler() {
|
||
|
|
if err := recover(); err != nil {
|
||
|
7 years ago
|
//TODO 全局日志记录
|
||
|
|
//LOGGER.Error("异步任务错误: %v", err)
|
||
|
7 years ago
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//带有panic恢复的方法
|
||
|
|
func SafeMethod(f func()) {
|
||
|
|
defer PanicHandler()
|
||
|
|
//执行函数
|
||
|
|
f()
|
||
|
|
}
|