common_error.go 752 Bytes
Newer Older
haoyanbin's avatar
1  
haoyanbin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
package wx

import "errors"

// CommonError 微信返回错误信息
type CommonError struct {
	ErrCode int    `json:"errcode"` // 	错误码
	ErrMSG  string `json:"errmsg"`  // 	错误描述
}

// GetResponseError 获取微信服务器错返回误信息
func (err *CommonError) GetResponseError() error {
	if err.ErrCode != 0 {
		return errors.New(err.ErrMSG)
	}

	return nil
}

// CommonResult 微信返回错误信息
type CommonResult struct {
	ResultCode int    `json:"resultcode"` // 	错误码
	ResultMsg  string `json:"resultmsg"`  // 	错误描述
}

// GetResponseError 获取微信服务器错返回误信息
func (err *CommonResult) GetResponseError() error {

	if err.ResultCode != 0 {
		return errors.New(err.ResultMsg)
	}

	return nil
}