mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-06 00:03:38 +00:00
Merge pull request #81 from chbmuc/master
Move error parsing behind status code handling
This commit is contained in:
@@ -128,12 +128,6 @@ func (client *OneDriveClient) call(url string, method string, input interface{},
|
|||||||
Error: OneDriveError { Status: response.StatusCode },
|
Error: OneDriveError { Status: response.StatusCode },
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.NewDecoder(response.Body).Decode(errorResponse); err != nil {
|
|
||||||
return nil, 0, OneDriveError { Status: response.StatusCode, Message: fmt.Sprintf("Unexpected response"), }
|
|
||||||
}
|
|
||||||
|
|
||||||
errorResponse.Error.Status = response.StatusCode
|
|
||||||
|
|
||||||
if response.StatusCode == 401 {
|
if response.StatusCode == 401 {
|
||||||
|
|
||||||
if url == OneDriveRefreshTokenURL {
|
if url == OneDriveRefreshTokenURL {
|
||||||
@@ -152,6 +146,12 @@ func (client *OneDriveClient) call(url string, method string, input interface{},
|
|||||||
backoff *= 2
|
backoff *= 2
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
if err := json.NewDecoder(response.Body).Decode(errorResponse); err != nil {
|
||||||
|
return nil, 0, OneDriveError { Status: response.StatusCode, Message: fmt.Sprintf("Unexpected response"), }
|
||||||
|
}
|
||||||
|
|
||||||
|
errorResponse.Error.Status = response.StatusCode
|
||||||
|
|
||||||
return nil, 0, errorResponse.Error
|
return nil, 0, errorResponse.Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user