添加文件: intelligence_finance_v1_ga/errors.go

This commit is contained in:
renzhiyuan 2026-08-17 16:13:10 +08:00
parent a65f2f32af
commit 793aa99471
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package intelligence_finance_v1_ga
import "fmt"
// APIError 表示 API 调用返回的错误。
type APIError struct {
// StatusCode HTTP 状态码。
StatusCode int
// Code 业务错误码。
Code int
// Message 错误信息。
Message string
}
// Error 实现 error 接口。
func (e *APIError) Error() string {
if e.Code != 0 {
return fmt.Sprintf("api error: code=%d, msg=%s", e.Code, e.Message)
}
return fmt.Sprintf("api error: http status=%d, body=%s", e.StatusCode, e.Message)
}