添加文件: sdk_LinkedMall/errors.go
This commit is contained in:
parent
06140f2530
commit
e4ef9e823a
|
|
@ -0,0 +1,45 @@
|
|||
package sdk_LinkedMall
|
||||
|
||||
import "fmt"
|
||||
|
||||
// APIError 表示API返回的业务错误
|
||||
type APIError struct {
|
||||
Code string `json:"Code"` // 错误码
|
||||
Message string `json:"Message"` // 错误信息
|
||||
SubCode string `json:"SubCode"` // 子错误码
|
||||
SubMessage string `json:"SubMessage"` // 子错误信息
|
||||
RequestId string `json:"RequestId"` // 请求ID
|
||||
}
|
||||
|
||||
func (e *APIError) Error() string {
|
||||
return fmt.Sprintf("linkedmall API error: code=%s, message=%s, subCode=%s, subMessage=%s, requestId=%s",
|
||||
e.Code, e.Message, e.SubCode, e.SubMessage, e.RequestId)
|
||||
}
|
||||
|
||||
// IsSuccess 判断是否业务成功
|
||||
func (e *APIError) IsSuccess() bool {
|
||||
return e.Code == "SUCCESS"
|
||||
}
|
||||
|
||||
// 预定义错误码常量
|
||||
const (
|
||||
ErrCodeShopTypeInvalid = "ShopTypeInvalid"
|
||||
ErrCodeSkuPriceNotLatest = "SkuPriceUnique"
|
||||
ErrCodePurchaseOrderNotFound = "PurchaseOrderNotFound"
|
||||
ErrCodeRefundNumberExceed = "RefundNumberMustLessThanOrder"
|
||||
ErrCodeRefundAmountExceed = "RefundAmountMustLessThanOrder"
|
||||
ErrCodeNoPrivilege = "HasNoPrivilege"
|
||||
ErrCodeOrderNotFound = "OrderNotFound"
|
||||
ErrCodeShopNotFound = "ShopNotFind"
|
||||
ErrCodeSavePurchaseOrderError = "SavePurchaseOrderError"
|
||||
ErrCodeOuterPurchaseOrderIdExist = "OuterPurchaseOrderIdExist"
|
||||
)
|
||||
|
||||
// ErrResp 用于解析错误响应
|
||||
type ErrResp struct {
|
||||
Code string `json:"Code"`
|
||||
Message string `json:"Message"`
|
||||
SubCode string `json:"SubCode"`
|
||||
SubMessage string `json:"SubMessage"`
|
||||
RequestId string `json:"RequestId"`
|
||||
}
|
||||
Loading…
Reference in New Issue