Refine the structure of this project.

This commit is contained in:
zicla
2019-04-26 14:32:15 +08:00
parent e88930e13a
commit c251ed9f1b
69 changed files with 5494 additions and 2251 deletions

View File

@ -1,8 +1,7 @@
package util
//带有panic恢复的方法
func PanicHandler() {
func PanicHandler() {
if err := recover(); err != nil {
//TODO 全局日志记录
//LOGGER.Error("异步任务错误: %v", err)
@ -10,11 +9,15 @@ func PanicHandler() {
}
//带有panic恢复的方法
func SafeMethod(f func()) {
func SafeMethod(f func()) {
defer PanicHandler()
//执行函数
f()
}
//处理错误的统一方法 可以省去if err!=nil 这段代码
func PanicError(err error) {
if err != nil {
panic(err)
}
}