26 lines
474 B
Go
26 lines
474 B
Go
|
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
|
||
|
}
|