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.
17 lines
257 B
17 lines
257 B
|
7 years ago
|
package rest
|
||
|
|
|
||
|
|
|
||
|
|
//带有panic恢复的方法
|
||
|
|
func PanicHandler() {
|
||
|
|
if err := recover(); err != nil {
|
||
|
|
LOGGER.Error("异步任务错误: %v", err)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//带有panic恢复的方法
|
||
|
|
func SafeMethod(f func()) {
|
||
|
|
defer PanicHandler()
|
||
|
|
//执行函数
|
||
|
|
f()
|
||
|
|
}
|