update
parent
43799a9841
commit
af5fef67db
|
@ -324,8 +324,12 @@ func (r *Request) doRequest(timeout time.Duration, method, rawUrl string) (*Resp
|
|||
copy(body, tmpBody)
|
||||
|
||||
if r.httpClient.config.noCheckStatus == false {
|
||||
if resp.StatusCode() != http.StatusOK {
|
||||
return nil, fmt.Errorf("status code err: %d (%s)", resp.StatusCode(), body)
|
||||
if resp.StatusCode() >= 400 {
|
||||
return nil, &StatusErr{
|
||||
StatusCode: resp.StatusCode(),
|
||||
Body: body,
|
||||
}
|
||||
//return nil, fmt.Errorf("status code err: %d (%s)", resp.StatusCode(), body)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,3 +368,14 @@ type Response struct {
|
|||
func (r *Response) GetBody() []byte {
|
||||
return r.body
|
||||
}
|
||||
|
||||
var _ error = (*StatusErr)(nil)
|
||||
|
||||
type StatusErr struct {
|
||||
StatusCode int
|
||||
Body []byte
|
||||
}
|
||||
|
||||
func (s *StatusErr) Error() string {
|
||||
return fmt.Sprintf("status code err: %d (%s)", s.StatusCode, s.Body)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue