From d68b091170d416a5fcc79cd6efa6d8f140f632fa Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 11 Jan 2019 14:14:37 +0000 Subject: [PATCH] hubic: make error message more informative if authentication fails --- backend/hubic/hubic.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/hubic/hubic.go b/backend/hubic/hubic.go index 955ab7d3d..feab504a4 100644 --- a/backend/hubic/hubic.go +++ b/backend/hubic/hubic.go @@ -9,8 +9,10 @@ package hubic import ( "encoding/json" "fmt" + "io/ioutil" "log" "net/http" + "strings" "time" "github.com/ncw/rclone/backend/swift" @@ -124,7 +126,9 @@ func (f *Fs) getCredentials() (err error) { } defer fs.CheckClose(resp.Body, &err) if resp.StatusCode < 200 || resp.StatusCode > 299 { - return errors.Errorf("failed to get credentials: %s", resp.Status) + body, _ := ioutil.ReadAll(resp.Body) + bodyStr := strings.TrimSpace(strings.Replace(string(body), "\n", " ", -1)) + return errors.Errorf("failed to get credentials: %s: %s", resp.Status, bodyStr) } decoder := json.NewDecoder(resp.Body) var result credentials