Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lfaoro committed Jul 9, 2018
1 parent 00caa51 commit 74c74a9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,28 @@ func (v *Vault) doRequest() (response *Response, err error) {

body, err := json.Marshal(v.request)
if err != nil {
return nil, err
return nil, fmt.Errorf("unable to marshall the request body: %v", err)
}
log.Debug("request: ", string(body))
req, err := http.NewRequest("POST", v.url, bytes.NewBuffer(body))
if err != nil {
return nil, err
return nil, fmt.Errorf("unable to create request: %v", err)
}
req.Header = setHeaders(body)
res, err := v.client.Do(req)
if err != nil {
return nil, err
return nil, fmt.Errorf("unable to perform http call: %v", err)
}
d, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
return nil, fmt.Errorf("unable to read response body: %v", err)
}
log.Debug("response body: ", string(d))
if err = json.Unmarshal(d, &response); err != nil {
return nil, err
return nil, fmt.Errorf("unable parse response body: %v", err)
}
if response.Error != "" {
return nil, fmt.Errorf("auric error: %v", response.Error)
return nil, fmt.Errorf("auric's message: %v", response.Error)
}
return response, nil
}

0 comments on commit 74c74a9

Please sign in to comment.