Fix http error handling
parent
74d2014541
commit
c42f7a8227
6
lib.go
6
lib.go
|
@ -54,7 +54,11 @@ func (c *Cli) Do(method string, strurl string, body []byte) (*http.Response, err
|
||||||
req.Header.Set(k, v)
|
req.Header.Set(k, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return c.cli.Do(req)
|
res,err:= c.cli.Do(req)
|
||||||
|
if err==nil && res.StatusCode >=400{
|
||||||
|
return nil, errors.New("Http return code - %d: %s",res.StatusCode,res.Status)
|
||||||
|
}
|
||||||
|
return res,err
|
||||||
}
|
}
|
||||||
func (c *Cli) DoJson(method string, strurl string, i interface{}, o interface{}) (err error) {
|
func (c *Cli) DoJson(method string, strurl string, i interface{}, o interface{}) (err error) {
|
||||||
bs, err := json.Marshal(i)
|
bs, err := json.Marshal(i)
|
||||||
|
|
Loading…
Reference in New Issue