mirror of
https://github.com/hanzoai/dashscope-go-sdk.git
synced 2026-09-30 21:39:25 +00:00
42 lines
746 B
Go
42 lines
746 B
Go
package httpclient
|
|
|
|
import (
|
|
"errors"
|
|
"strconv"
|
|
)
|
|
|
|
var ErrNetwork = errors.New("network error")
|
|
|
|
type EmptyRequestBodyError struct {
|
|
Method string
|
|
}
|
|
|
|
func (e *EmptyRequestBodyError) Error() string {
|
|
return "POST or PUT request body cannot be empty for method " + e.Method
|
|
}
|
|
|
|
type WrapMessageError struct {
|
|
Message string
|
|
Cause error
|
|
}
|
|
|
|
func (e *WrapMessageError) Error() string {
|
|
if e.Cause == nil {
|
|
return e.Message
|
|
}
|
|
return e.Message + ": " + e.Cause.Error()
|
|
}
|
|
|
|
type HTTPRequestError struct {
|
|
Message string
|
|
Cause error
|
|
Code int
|
|
}
|
|
|
|
func (e *HTTPRequestError) Error() string {
|
|
if e.Cause == nil {
|
|
return e.Message + ": " + strconv.Itoa(e.Code)
|
|
}
|
|
return e.Message + ": " + strconv.Itoa(e.Code) + " " + e.Cause.Error()
|
|
}
|