github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/core/error.go (about) 1 package core 2 3 import ( 4 "fmt" 5 "reflect" 6 ) 7 8 const ( 9 ErrCodeOK = 0 10 ErrCodeInvalidCredential = 40001 // access_token 过期错误码 11 ErrCodeAccessTokenExpired = 42001 // access_token 过期错误码(maybe!!!) 12 ) 13 14 var ( 15 errorType = reflect.TypeOf(Error{}) 16 errorZeroValue = reflect.Zero(errorType) 17 ) 18 19 const ( 20 errorErrCodeIndex = 0 21 errorErrMsgIndex = 1 22 ) 23 24 type Error struct { 25 ErrCode int64 `json:"errcode"` 26 ErrMsg string `json:"errmsg"` 27 } 28 29 func (err *Error) Error() string { 30 return fmt.Sprintf("errcode: %d, errmsg: %s", err.ErrCode, err.ErrMsg) 31 }