iedc-go/error.go

42 lines
460 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 (
"fmt"
)
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{
fmt.Println(err)
}
2017-11-14 10:27:09 +00:00
if lev==LOG_FILE{
fmt.Println(err)
}
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
}