封装的方法类
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package panicx
|
||||
|
||||
import (
|
||||
// "errors"
|
||||
// "bop_notify/global"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
// "os"
|
||||
"runtime/debug"
|
||||
// "time"
|
||||
)
|
||||
|
||||
func PanicCatch(a *error) (b bool) {
|
||||
// *a = errors.New("fff")
|
||||
errs := recover()
|
||||
// fmt.Printf("这是全局捕捉的 %T \n", errs)
|
||||
if errs == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
fmt.Println("Recover Error:", errs)
|
||||
log.Println("errMsg", errs)
|
||||
log.Println("errStack", string(debug.Stack()))
|
||||
|
||||
*a = errors.New("recover捕捉到异常")
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user