Commit b1bdf6c0 by zhengqiuyun86

协程执行器

parent ed2c6efb
package GoroutineExecutor
import (
"git.168cad.top/zhengqiuyun/rym-util/exception/catch"
)
func do(f func()) {
defer catch.ExceptionCatch(nil)
f()
}
func SynDo(f func()) {
go do(f)
}
...@@ -21,17 +21,36 @@ func ExceptionCatch(c *gin.Context) { ...@@ -21,17 +21,36 @@ func ExceptionCatch(c *gin.Context) {
getWay.FailAndMsg(c, e.Code, e.Err) getWay.FailAndMsg(c, e.Code, e.Err)
} }
break break
default: case error:
e := (err).(error) e := (err).(error)
var buf [1024]byte
n := runtime.Stack(buf[:], true)
fmt.Println(string(buf[:]), n)
if c == nil { if c == nil {
log.Error(e.Error()) log.Error(e.Error())
} else { } else {
getWay.FailAndMsg(c, "SYSTEM.ERROR", e.Error()) getWay.FailAndMsg(c, "SYSTEM.ERROR", e.Error())
} }
printStack()
break
case string:
e := (err).(string)
if c == nil {
log.Error(e)
} else {
getWay.FailAndMsg(c, "SYSTEM.ERROR", e)
}
printStack()
break
default:
if c != nil {
getWay.FailAndMsg(c, "SYSTEM.ERROR", "系统繁忙...")
}
printStack()
break break
} }
} }
} }
func printStack() {
var buf [1024]byte
n := runtime.Stack(buf[:], true)
fmt.Println(string(buf[:]), n)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment