From af1eaafe0cd9862832ef42fdc2f4798c3fd154ed Mon Sep 17 00:00:00 2001 From: renzhiyuan <465386466@qq.com> Date: Mon, 17 Aug 2026 17:04:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6:=20intelli?= =?UTF-8?q?gence=5Ffinance=5Fv1=5Fga/errors.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- intelligence_finance_v1_ga/errors.go | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 intelligence_finance_v1_ga/errors.go diff --git a/intelligence_finance_v1_ga/errors.go b/intelligence_finance_v1_ga/errors.go new file mode 100644 index 0000000..bb7e618 --- /dev/null +++ b/intelligence_finance_v1_ga/errors.go @@ -0,0 +1,40 @@ +package intelligence_finance_v1_ga + +import "fmt" + +// APIError 表示 HTTP 层面的错误(非 200 响应)。 +type APIError struct { + // StatusCode HTTP 状态码 + StatusCode int + // Body 响应体原始内容 + Body string +} + +// Error 实现 error 接口。 +func (e *APIError) Error() string { + return fmt.Sprintf("api error: status=%d body=%s", e.StatusCode, e.Body) +} + +// BusinessError 表示业务层面的错误(通用响应结构中 code 非成功值)。 +type BusinessError struct { + // Code 业务错误码 + Code int + // Msg 业务错误描述 + Msg string +} + +// Error 实现 error 接口。 +func (e *BusinessError) Error() string { + return fmt.Sprintf("business error: code=%d msg=%s", e.Code, e.Msg) +} + +// NotificationError 表示通知处理失败。 +type NotificationError struct { + // Reason 失败原因 + Reason string +} + +// Error 实现 error 接口。 +func (e *NotificationError) Error() string { + return fmt.Sprintf("notification error: %s", e.Reason) +} \ No newline at end of file