- 将一些需要返回json信息的错误,正式编码,从-101开始

This commit is contained in:
gazebo
2019-07-12 14:29:38 +08:00
parent 166675232c
commit 7d59d1d0f1
3 changed files with 25 additions and 10 deletions

View File

@@ -3,14 +3,16 @@ package jsonerr
import "git.rosy.net.cn/baseapi/utils"
type Error struct {
Obj interface{}
ObjStr string
errCode string
Obj interface{}
ObjStr string
}
func New(obj interface{}) (err *Error) {
func New(obj interface{}, errCode string) (err *Error) {
return &Error{
Obj: obj,
ObjStr: string(utils.MustMarshal(obj)),
errCode: errCode,
Obj: obj,
ObjStr: string(utils.MustMarshal(obj)),
}
}
@@ -22,3 +24,7 @@ func IsJsonErr(err error) bool {
func (e *Error) Error() string {
return e.ObjStr
}
func (e *Error) ErrCode() string {
return e.errCode
}