diff --git a/lib.go b/lib.go index bb66a61..34ef38d 100644 --- a/lib.go +++ b/lib.go @@ -54,7 +54,11 @@ func (c *Cli) Do(method string, strurl string, body []byte) (*http.Response, err 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) { bs, err := json.Marshal(i)