Fix abnormal termination when no internet connection (#643)

* Fix abnormal termination when no internet connection
This commit is contained in:
abraunegg 2019-09-06 13:12:13 +10:00 committed by GitHub
parent 90a28e0f6c
commit 0424caaaf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -415,6 +415,7 @@ final class OneDriveApi
private void acquireToken(const(char)[] postData)
{
JSONValue response = post(tokenUrl, postData);
if (response.type() == JSONType.object) {
if ("access_token" in response){
accessToken = "bearer " ~ response["access_token"].str();
refreshToken = response["refresh_token"].str();
@ -428,6 +429,9 @@ final class OneDriveApi
// re-authorize
authorize();
}
} else {
log.vdebug("Invalid JSON response from OneDrive unable to initialize application");
}
}
private void checkAccessTokenExpired()
@ -611,18 +615,18 @@ final class OneDriveApi
if (.debugResponse){
writeln("OneDrive HTTP Server Response: ", http.statusLine.code);
}
return data.length;
};
JSONValue json;
try {
http.perform();
} catch (CurlException e) {
// Potentially Timeout was reached on handle error
log.error("\nThere was a problem in accessing the Microsoft OneDrive service - Internet connectivity issue?\n");
log.error("ERROR: There was a timeout in accessing the Microsoft OneDrive service - Internet connectivity issue?");
return json;
}
JSONValue json;
try {
json = content.parseJSON();
} catch (JSONException e) {