Update error catching and handling

* Update error catching and handling
This commit is contained in:
abraunegg 2020-11-13 05:42:24 +11:00
parent 68cc51ab4d
commit cc2b8085f5
2 changed files with 17 additions and 2 deletions

View file

@ -493,8 +493,17 @@ final class OneDriveApi
{
checkAccessTokenExpired();
scope(failure) {
if (exists(saveToPath)) remove(saveToPath);
if (exists(saveToPath)) {
// try and remove the file, catch error
try {
remove(saveToPath);
} catch (FileException e) {
// display the error message
displayFileSystemErrorMessage(e.msg);
}
}
}
// Create the directory
string newPath = dirName(saveToPath);
mkdirRecurse(newPath);
@ -803,6 +812,7 @@ final class OneDriveApi
{
// Threshold for displaying download bar
long thresholdFileSize = 4 * 2^^20; // 4 MiB
// open file as write in binary mode
auto file = File(filename, "wb");
// function scopes

View file

@ -2565,7 +2565,6 @@ final class SyncEngine
log.vdebug("onedrive.downloadById(item.driveId, item.id, path, fileSize); generated a OneDriveException");
// 408 = Request Time Out
// 429 = Too Many Requests - need to delay
if (e.httpStatusCode == 408) {
// 408 error handling - request time out
// https://github.com/abraunegg/onedrive/issues/694
@ -2637,6 +2636,12 @@ final class SyncEngine
}
}
}
} catch (FileException e) {
// There was a file system error
// display the error message
displayFileSystemErrorMessage(e.msg);
downloadFailed = true;
return;
} catch (std.exception.ErrnoException e) {
// There was a file system error
// display the error message