附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common_error.go 755 B

2 月之前
12345678910111213141516171819202122232425262728293031323334
  1. package weapp
  2. import "errors"
  3. // CommonError 微信返回错误信息
  4. type CommonError struct {
  5. ErrCode int `json:"errcode"` // 错误码
  6. ErrMSG string `json:"errmsg"` // 错误描述
  7. }
  8. // GetResponseError 获取微信服务器错返回误信息
  9. func (err *CommonError) GetResponseError() error {
  10. if err.ErrCode != 0 {
  11. return errors.New(err.ErrMSG)
  12. }
  13. return nil
  14. }
  15. // CommonResult 微信返回错误信息
  16. type CommonResult struct {
  17. ResultCode int `json:"resultcode"` // 错误码
  18. ResultMsg string `json:"resultmsg"` // 错误描述
  19. }
  20. // GetResponseError 获取微信服务器错返回误信息
  21. func (err *CommonResult) GetResponseError() error {
  22. if err.ResultCode != 0 {
  23. return errors.New(err.ResultMsg)
  24. }
  25. return nil
  26. }