26 lines
474 B
Go
Raw Normal View History

2021-10-28 00:59:04 +08:00
package request
import "fmt"
type Error struct {
Code int32 `json:"errcode"`
Msg string `json:"errmsg"`
}
func (err Error) IsZero() bool {
// return reflect.DeepEqual(err, Error{}) || reflect.DeepEqual(err, Error{Code: 0, Msg: "ok"})
return err.Code == 0
}
func (err Error) Error() string {
text := ErrCodeText[err.Code]
return fmt.Sprintf("%d:%s, %s", err.Code, err.Msg, text)
}
func (err Error) Err() error {
if err.Code == 0 {
return nil
}
return err
}