diff --git a/ymt_v3/errors.go b/ymt_v3/errors.go new file mode 100644 index 0000000..71571a0 --- /dev/null +++ b/ymt_v3/errors.go @@ -0,0 +1,17 @@ +package ymt_v3 + +import "fmt" + +// APIError 表示API返回的错误信息 +type APIError struct { + Code int32 `json:"code"` + Message string `json:"message"` + Reason string `json:"reason,omitempty"` +} + +func (e *APIError) Error() string { + if e.Reason != "" { + return fmt.Sprintf("code=%d, message=%s, reason=%s", e.Code, e.Message, e.Reason) + } + return fmt.Sprintf("code=%d, message=%s", e.Code, e.Message) +} \ No newline at end of file