19 lines
508 B
Go
19 lines
508 B
Go
package wxcore
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// 异常处理
|
|
func TryE(userName string) {
|
|
errs := recover()
|
|
if errs == nil {
|
|
return
|
|
}
|
|
now := time.Now() //获取当前时间
|
|
timeFormat := now.Format("2006-01-02 15:04:05") //设定时间格式
|
|
fileName := fmt.Sprintf("[%s]-%s-%vrn", userName, timeFormat, errs) //保存错误信息文件名:程序名-进程ID-当前时间(年月日时分秒)
|
|
fmt.Println("error: ", fileName)
|
|
}
|