From 74c74a97e926b8affdf6403f8d3ac4e3e2b7f76c Mon Sep 17 00:00:00 2001 From: Leonardo Faoro Date: Mon, 9 Jul 2018 17:31:44 +0200 Subject: [PATCH] Improve error messages --- utils.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils.go b/utils.go index cd2e019..a85fc7d 100644 --- a/utils.go +++ b/utils.go @@ -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 }