response.go 865 B

123456789101112131415161718192021222324252627282930313233343536
  1. package http
  2. import (
  3. "fmt"
  4. )
  5. // CommonError 微信返回错误信息
  6. type CommonError struct {
  7. ErrCode int `json:"errcode"` // 错误码
  8. ErrMSG string `json:"errmsg"` // 错误描述
  9. }
  10. // GetResponseError 获取微信服务器错返回误信息
  11. func (err CommonError) GetResponseError() error {
  12. if err.ErrCode != 0 {
  13. return fmt.Errorf("wechat server error: code[%d] msg[%s]", err.ErrCode, err.ErrMSG)
  14. }
  15. return nil
  16. }
  17. // CommonResult 微信返回错误信息
  18. type CommonResult struct {
  19. ResultCode int `json:"resultcode"` // 错误码
  20. ResultMsg string `json:"resultmsg"` // 错误描述
  21. }
  22. // GetResponseError 获取微信服务器错返回误信息
  23. func (err CommonResult) GetResponseError() error {
  24. if err.ResultCode != 0 {
  25. return fmt.Errorf("wechat server error: code[%d] msg[%s]", err.ResultCode, err.ResultMsg)
  26. }
  27. return nil
  28. }