添加文件: intelligence_finance_v1_ga/errors.go
This commit is contained in:
parent
f401aa18e1
commit
af1eaafe0c
|
|
@ -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)
|
||||
}
|
||||
Loading…
Reference in New Issue