Fix to parse API error
This commit is contained in:
parent
fe02b9e6af
commit
aa0f9563ac
4 changed files with 21 additions and 7 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
|
@ -131,7 +130,7 @@ func (c *Client) doAPI(ctx context.Context, method string, uri string, params in
|
|||
}
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("bad request: %v", resp.Status)
|
||||
return parseAPIError("bad request", resp)
|
||||
} else if res == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -175,7 +174,7 @@ func (c *Client) Authenticate(ctx context.Context, username, password string) er
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("bad authorization: %v", resp.Status)
|
||||
return parseAPIError("bad authorization", resp)
|
||||
}
|
||||
|
||||
res := struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue