hubic: make error message more informative if authentication fails
This commit is contained in:
parent
d809bed438
commit
d68b091170
1 changed files with 5 additions and 1 deletions
|
@ -9,8 +9,10 @@ package hubic
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ncw/rclone/backend/swift"
|
"github.com/ncw/rclone/backend/swift"
|
||||||
|
@ -124,7 +126,9 @@ func (f *Fs) getCredentials() (err error) {
|
||||||
}
|
}
|
||||||
defer fs.CheckClose(resp.Body, &err)
|
defer fs.CheckClose(resp.Body, &err)
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
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)
|
decoder := json.NewDecoder(resp.Body)
|
||||||
var result credentials
|
var result credentials
|
||||||
|
|
Loading…
Reference in a new issue