From c4212042bfa4c9fddeb908f607b4ffa84d0060e8 Mon Sep 17 00:00:00 2001 From: renzhiyuan <465386466@qq.com> Date: Thu, 23 Jul 2026 17:07:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6:=20ymt=5Fv?= =?UTF-8?q?3/errors.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ymt_v3/errors.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ymt_v3/errors.go 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