添加文件: ymt_v3/errors.go

This commit is contained in:
renzhiyuan 2026-07-23 17:07:09 +08:00
parent 00c7b387e9
commit c4212042bf
1 changed files with 17 additions and 0 deletions

17
ymt_v3/errors.go Normal file
View File

@ -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)
}