17 lines
411 B
Go
17 lines
411 B
Go
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)
|
|
} |