Handle OneDrive error response on creating upload session (#556)

* Add a try block when attempting to create the upload session and handle if there is an error response from OneDrive
* Should return a JSONValue regardless of error
This commit is contained in:
abraunegg 2019-06-27 18:40:18 +10:00 committed by GitHub
parent 14fb1ca637
commit 15a2749382
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,10 +39,19 @@ struct UploadSession
])
];
session = onedrive.createUploadSession(parentDriveId, parentId, filename, eTag, fileSystemInfo);
session["localPath"] = localPath;
save();
return upload();
try {
// Try to create the upload session for this file
session = onedrive.createUploadSession(parentDriveId, parentId, filename, eTag, fileSystemInfo);
session["localPath"] = localPath;
save();
return upload();
} catch (OneDriveException e) {
// there was an error
log.vlog("Create file upload session failed ... skipping file upload");
// return upload() will return a JSONValue response, create an empty JSONValue response to return
JSONValue response;
return response;
}
}
/* Restore the previous upload session.