hotime/error.go

43 lines
461 B
Go
Raw Normal View History

2017-08-04 08:20:59 +00:00
package hotime
2018-04-03 17:54:27 +00:00
import (
2019-07-01 04:35:04 +00:00
"log"
2018-04-03 17:54:27 +00:00
)
2017-08-04 08:20:59 +00:00
//框架层处理错误
type Error struct {
err error
}
func(this *Error)GetError()error{
return this.err
}
2017-08-16 09:15:51 +00:00
func(this *Error)SetError(err error,loglevel ...int){
2017-08-04 08:20:59 +00:00
2018-04-03 17:54:27 +00:00
2017-08-16 09:15:51 +00:00
this.err=nil
2017-08-04 08:20:59 +00:00
if err==nil{
this.err=err
2018-04-03 17:54:27 +00:00
return
2017-08-04 08:20:59 +00:00
}
2018-04-07 16:54:08 +00:00
lev:=Config.GetInt("logLevel")
2017-08-04 08:20:59 +00:00
if len(loglevel)!=0{
lev=loglevel[0]
}
if lev==LOG_FMT{
2019-07-01 04:35:04 +00:00
log.Println(err)
2017-08-04 08:20:59 +00:00
}
2017-11-14 10:27:09 +00:00
if lev==LOG_FILE{
2019-07-01 04:35:04 +00:00
log.Println(err)
2017-11-14 10:27:09 +00:00
}
2017-08-04 08:20:59 +00:00
this.err=err
2018-04-03 17:54:27 +00:00
return
2017-08-04 08:20:59 +00:00
}