mirror of
https://github.com/abraunegg/onedrive
synced 2024-04-27 11:51:59 +02:00
Remove duplicate code for error output functions and enhance error logging output (#1170)
* Remove duplicate code for error output functions and enhance error logging output
This commit is contained in:
parent
335eab326d
commit
3b18638a63
|
@ -151,7 +151,7 @@ final class Monitor
|
||||||
// catch any error which is generated
|
// catch any error which is generated
|
||||||
} catch (std.file.FileException e) {
|
} catch (std.file.FileException e) {
|
||||||
// Standard filesystem error
|
// Standard filesystem error
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Issue #1154 handling
|
// Issue #1154 handling
|
||||||
|
@ -166,7 +166,7 @@ final class Monitor
|
||||||
exit(-1);
|
exit(-1);
|
||||||
} else {
|
} else {
|
||||||
// some other error
|
// some other error
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,12 +388,4 @@ final class Monitor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse and display error message received from the local file system
|
|
||||||
private void displayFileSystemErrorMessage(string message)
|
|
||||||
{
|
|
||||||
log.error("ERROR: The local file system returned an error with the following message:");
|
|
||||||
auto errorArray = splitLines(message);
|
|
||||||
log.error(" Error Message: ", errorArray[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import core.thread, std.conv, std.math;
|
||||||
import std.algorithm.searching;
|
import std.algorithm.searching;
|
||||||
import progress;
|
import progress;
|
||||||
import config;
|
import config;
|
||||||
|
import util;
|
||||||
static import log;
|
static import log;
|
||||||
shared bool debugResponse = false;
|
shared bool debugResponse = false;
|
||||||
private bool dryRun = false;
|
private bool dryRun = false;
|
||||||
|
@ -402,7 +403,7 @@ final class OneDriveApi
|
||||||
response = cast(char[]) read(responseUrl);
|
response = cast(char[]) read(responseUrl);
|
||||||
} catch (OneDriveException e) {
|
} catch (OneDriveException e) {
|
||||||
// exception generated
|
// exception generated
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,7 +536,7 @@ final class OneDriveApi
|
||||||
remove(saveToPath);
|
remove(saveToPath);
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,7 +554,7 @@ final class OneDriveApi
|
||||||
newPath.setAttributes(cfg.returnRequiredDirectoryPermisions());
|
newPath.setAttributes(cfg.returnRequiredDirectoryPermisions());
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,7 +781,7 @@ final class OneDriveApi
|
||||||
response = post(tokenUrl, postData);
|
response = post(tokenUrl, postData);
|
||||||
} catch (OneDriveException e) {
|
} catch (OneDriveException e) {
|
||||||
// an error was generated
|
// an error was generated
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.type() == JSONType.object) {
|
if (response.type() == JSONType.object) {
|
||||||
|
@ -796,7 +797,7 @@ final class OneDriveApi
|
||||||
cfg.refreshTokenFilePath.setAttributes(cfg.returnRequiredFilePermisions());
|
cfg.refreshTokenFilePath.setAttributes(cfg.returnRequiredFilePermisions());
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (printAccessToken) writeln("New access token: ", accessToken);
|
if (printAccessToken) writeln("New access token: ", accessToken);
|
||||||
|
@ -939,7 +940,7 @@ final class OneDriveApi
|
||||||
writeln();
|
writeln();
|
||||||
// Reset onProgress to not display anything for next download done using exit scope
|
// Reset onProgress to not display anything for next download done using exit scope
|
||||||
} catch (CurlException e) {
|
} catch (CurlException e) {
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
// free progress bar memory
|
// free progress bar memory
|
||||||
p = null;
|
p = null;
|
||||||
|
@ -949,7 +950,7 @@ final class OneDriveApi
|
||||||
// try and catch any curl error
|
// try and catch any curl error
|
||||||
http.perform();
|
http.perform();
|
||||||
} catch (CurlException e) {
|
} catch (CurlException e) {
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1081,10 +1082,11 @@ final class OneDriveApi
|
||||||
log.error("ERROR: OneDrive returned an error with the following message:");
|
log.error("ERROR: OneDrive returned an error with the following message:");
|
||||||
auto errorArray = splitLines(e.msg);
|
auto errorArray = splitLines(e.msg);
|
||||||
string errorMessage = errorArray[0];
|
string errorMessage = errorArray[0];
|
||||||
|
string defaultTimeoutErrorMessage = " Error Message: There was a timeout in accessing the Microsoft OneDrive service - Internet connectivity issue?";
|
||||||
|
|
||||||
if (canFind(errorMessage, "Couldn't connect to server on handle") || canFind(errorMessage, "Couldn't resolve host name on handle")) {
|
if (canFind(errorMessage, "Couldn't connect to server on handle") || canFind(errorMessage, "Couldn't resolve host name on handle") || canFind(errorMessage, "Timeout was reached on handle")) {
|
||||||
// This is a curl timeout
|
// This is a curl timeout
|
||||||
log.error(" Error Message: There was a timeout in accessing the Microsoft OneDrive service - Internet connectivity issue?");
|
log.error(defaultTimeoutErrorMessage);
|
||||||
// or 408 request timeout
|
// or 408 request timeout
|
||||||
// https://github.com/abraunegg/onedrive/issues/694
|
// https://github.com/abraunegg/onedrive/issues/694
|
||||||
// Back off & retry with incremental delay
|
// Back off & retry with incremental delay
|
||||||
|
@ -1110,8 +1112,8 @@ final class OneDriveApi
|
||||||
log.log("Internet connectivity to Microsoft OneDrive service has been restored");
|
log.log("Internet connectivity to Microsoft OneDrive service has been restored");
|
||||||
retrySuccess = true;
|
retrySuccess = true;
|
||||||
} catch (CurlException e) {
|
} catch (CurlException e) {
|
||||||
if (canFind(e.msg, "Couldn't connect to server on handle") || canFind(e.msg, "Couldn't resolve host name on handle")) {
|
if (canFind(e.msg, "Couldn't connect to server on handle") || canFind(e.msg, "Couldn't resolve host name on handle") || canFind(errorMessage, "Timeout was reached on handle")) {
|
||||||
log.error(" Error Message: There was a timeout in accessing the Microsoft OneDrive service - Internet connectivity issue?");
|
log.error(defaultTimeoutErrorMessage);
|
||||||
// Increment & loop around
|
// Increment & loop around
|
||||||
retryAttempts++;
|
retryAttempts++;
|
||||||
}
|
}
|
||||||
|
@ -1129,6 +1131,7 @@ final class OneDriveApi
|
||||||
} else {
|
} else {
|
||||||
// Some other error was returned
|
// Some other error was returned
|
||||||
log.error(" Error Message: ", errorMessage);
|
log.error(" Error Message: ", errorMessage);
|
||||||
|
log.error(" Calling Function: ", getFunctionName!({}));
|
||||||
}
|
}
|
||||||
// return an empty JSON for handling
|
// return an empty JSON for handling
|
||||||
return json;
|
return json;
|
||||||
|
@ -1365,29 +1368,6 @@ final class OneDriveApi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse and display error message received from OneDrive
|
|
||||||
private void displayOneDriveErrorMessage(string message) {
|
|
||||||
log.error("\nERROR: OneDrive returned an error with the following message:");
|
|
||||||
auto errorArray = splitLines(message);
|
|
||||||
log.error(" Error Message: ", errorArray[0]);
|
|
||||||
// Strip cause from error to leave a JSON
|
|
||||||
JSONValue errorMessage = parseJSON(replace(message, errorArray[0], ""));
|
|
||||||
// extra debug
|
|
||||||
log.vdebug("Raw Error Data: ", message);
|
|
||||||
log.vdebug("JSON Message: ", errorMessage);
|
|
||||||
if (errorMessage.type() == JSONType.object) {
|
|
||||||
log.error(" Error Reason: ", errorMessage["error_description"].str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse and display error message received from the local file system
|
|
||||||
private void displayFileSystemErrorMessage(string message)
|
|
||||||
{
|
|
||||||
log.error("ERROR: The local file system returned an error with the following message:");
|
|
||||||
auto errorArray = splitLines(message);
|
|
||||||
log.error(" Error Message: ", errorArray[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
|
191
src/sync.d
191
src/sync.d
|
@ -297,7 +297,7 @@ final class SyncEngine
|
||||||
log.vdebug("oneDriveDetails = onedrive.getDefaultDrive() generated a OneDriveException");
|
log.vdebug("oneDriveDetails = onedrive.getDefaultDrive() generated a OneDriveException");
|
||||||
if (e.httpStatusCode == 400) {
|
if (e.httpStatusCode == 400) {
|
||||||
// OneDrive responded with 400 error: Bad Request
|
// OneDrive responded with 400 error: Bad Request
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
|
|
||||||
// Check this
|
// Check this
|
||||||
if (cfg.getValueString("drive_id").length) {
|
if (cfg.getValueString("drive_id").length) {
|
||||||
|
@ -308,7 +308,7 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
if (e.httpStatusCode == 401) {
|
if (e.httpStatusCode == 401) {
|
||||||
// HTTP request returned status code 401 (Unauthorized)
|
// HTTP request returned status code 401 (Unauthorized)
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
log.errorAndNotify("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n");
|
log.errorAndNotify("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n");
|
||||||
// Must exit here
|
// Must exit here
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -324,7 +324,7 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
if (e.httpStatusCode >= 500) {
|
if (e.httpStatusCode >= 500) {
|
||||||
// There was a HTTP 5xx Server Side Error
|
// There was a HTTP 5xx Server Side Error
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
// Must exit here
|
// Must exit here
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ final class SyncEngine
|
||||||
log.vdebug("oneDriveRootDetails = onedrive.getDefaultRoot() generated a OneDriveException");
|
log.vdebug("oneDriveRootDetails = onedrive.getDefaultRoot() generated a OneDriveException");
|
||||||
if (e.httpStatusCode == 400) {
|
if (e.httpStatusCode == 400) {
|
||||||
// OneDrive responded with 400 error: Bad Request
|
// OneDrive responded with 400 error: Bad Request
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
// Check this
|
// Check this
|
||||||
if (cfg.getValueString("drive_id").length) {
|
if (cfg.getValueString("drive_id").length) {
|
||||||
log.error("\nERROR: Check your 'drive_id' entry in your configuration file as it may be incorrect\n");
|
log.error("\nERROR: Check your 'drive_id' entry in your configuration file as it may be incorrect\n");
|
||||||
|
@ -347,7 +347,7 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
if (e.httpStatusCode == 401) {
|
if (e.httpStatusCode == 401) {
|
||||||
// HTTP request returned status code 401 (Unauthorized)
|
// HTTP request returned status code 401 (Unauthorized)
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
log.errorAndNotify("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n");
|
log.errorAndNotify("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n");
|
||||||
// Must exit here
|
// Must exit here
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -363,7 +363,7 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
if (e.httpStatusCode >= 500) {
|
if (e.httpStatusCode >= 500) {
|
||||||
// There was a HTTP 5xx Server Side Error
|
// There was a HTTP 5xx Server Side Error
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
// Must exit here
|
// Must exit here
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -1327,7 +1327,7 @@ final class SyncEngine
|
||||||
// HTTP request returned status code 500 (Internal Server Error)
|
// HTTP request returned status code 500 (Internal Server Error)
|
||||||
if (e.httpStatusCode == 500) {
|
if (e.httpStatusCode == 500) {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1352,13 +1352,13 @@ final class SyncEngine
|
||||||
// display what the error is
|
// display what the error is
|
||||||
log.vdebug("Query Error: changes = generateDeltaResponse(driveId, idToQuery) on re-try after delay");
|
log.vdebug("Query Error: changes = generateDeltaResponse(driveId, idToQuery) on re-try after delay");
|
||||||
// error was not a 504 this time
|
// error was not a 504 this time
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Default operation if not 404, 410, 429, 500 or 504 errors
|
// Default operation if not 404, 410, 429, 500 or 504 errors
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1368,13 +1368,14 @@ final class SyncEngine
|
||||||
try {
|
try {
|
||||||
// Fetch the changes relative to the path id we want to query
|
// Fetch the changes relative to the path id we want to query
|
||||||
log.vdebug("Attempting query 'changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink)'");
|
log.vdebug("Attempting query 'changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink)'");
|
||||||
log.vdebug("driveId: ", driveId);
|
log.vdebug("driveId: ", driveId);
|
||||||
log.vdebug("idToQuery: ", idToQuery);
|
log.vdebug("idToQuery: ", idToQuery);
|
||||||
log.vdebug("deltaLink: ", deltaLink);
|
log.vdebug("Previous deltaLink: ", deltaLink);
|
||||||
// changes with or without deltaLink
|
// changes with or without deltaLink
|
||||||
changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink);
|
changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink);
|
||||||
if (changes.type() == JSONType.object) {
|
if (changes.type() == JSONType.object) {
|
||||||
log.vdebug("Query 'changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink)' performed successfully");
|
log.vdebug("Query 'changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink)' performed successfully");
|
||||||
|
log.vdebug("OneDrive API /delta response: ", changes);
|
||||||
}
|
}
|
||||||
} catch (OneDriveException e) {
|
} catch (OneDriveException e) {
|
||||||
// OneDrive threw an error
|
// OneDrive threw an error
|
||||||
|
@ -1407,7 +1408,7 @@ final class SyncEngine
|
||||||
// HTTP request returned status code 500 (Internal Server Error)
|
// HTTP request returned status code 500 (Internal Server Error)
|
||||||
if (e.httpStatusCode == 500) {
|
if (e.httpStatusCode == 500) {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1441,12 +1442,12 @@ final class SyncEngine
|
||||||
log.vdebug("Query 'changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink)' performed successfully on re-try");
|
log.vdebug("Query 'changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink)' performed successfully on re-try");
|
||||||
} catch (OneDriveException e) {
|
} catch (OneDriveException e) {
|
||||||
// Tried 3 times, give up
|
// Tried 3 times, give up
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// error was not a 504 this time
|
// error was not a 504 this time
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1459,7 +1460,7 @@ final class SyncEngine
|
||||||
itemdb.setDeltaLink(driveId, idToQuery, emptyDeltaLink);
|
itemdb.setDeltaLink(driveId, idToQuery, emptyDeltaLink);
|
||||||
}
|
}
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1512,7 +1513,7 @@ final class SyncEngine
|
||||||
// HTTP request returned status code 500 (Internal Server Error)
|
// HTTP request returned status code 500 (Internal Server Error)
|
||||||
if (e.httpStatusCode == 500) {
|
if (e.httpStatusCode == 500) {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1546,19 +1547,19 @@ final class SyncEngine
|
||||||
log.vdebug("Query 'changesAvailable = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLinkAvailable)' performed successfully on re-try");
|
log.vdebug("Query 'changesAvailable = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLinkAvailable)' performed successfully on re-try");
|
||||||
} catch (OneDriveException e) {
|
} catch (OneDriveException e) {
|
||||||
// Tried 3 times, give up
|
// Tried 3 times, give up
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// error was not a 504 this time
|
// error was not a 504 this time
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Default operation if not 404, 410, 429, 500 or 504 errors
|
// Default operation if not 404, 410, 429, 500 or 504 errors
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1784,12 +1785,12 @@ final class SyncEngine
|
||||||
log.vlog("Remote change discarded - item cannot be found");
|
log.vlog("Remote change discarded - item cannot be found");
|
||||||
} else {
|
} else {
|
||||||
// not a 404
|
// not a 404
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not a 404 or a 429
|
// not a 404 or a 429
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2455,7 +2456,7 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
// flag that this failed
|
// flag that this failed
|
||||||
downloadFailed = true;
|
downloadFailed = true;
|
||||||
return;
|
return;
|
||||||
|
@ -2517,7 +2518,7 @@ final class SyncEngine
|
||||||
setTimes(newPath, newItem.mtime, newItem.mtime);
|
setTimes(newPath, newItem.mtime, newItem.mtime);
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2630,7 +2631,7 @@ final class SyncEngine
|
||||||
retryAttempts++;
|
retryAttempts++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2665,7 +2666,7 @@ final class SyncEngine
|
||||||
retryAttempts++;
|
retryAttempts++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2673,13 +2674,13 @@ final class SyncEngine
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// There was a file system error
|
// There was a file system error
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
downloadFailed = true;
|
downloadFailed = true;
|
||||||
return;
|
return;
|
||||||
} catch (std.exception.ErrnoException e) {
|
} catch (std.exception.ErrnoException e) {
|
||||||
// There was a file system error
|
// There was a file system error
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
downloadFailed = true;
|
downloadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2698,7 +2699,7 @@ final class SyncEngine
|
||||||
setTimes(path, item.mtime, item.mtime);
|
setTimes(path, item.mtime, item.mtime);
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// size error?
|
// size error?
|
||||||
|
@ -2814,7 +2815,7 @@ final class SyncEngine
|
||||||
rmdirRecurse(path);
|
rmdirRecurse(path);
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3365,14 +3366,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3402,14 +3403,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3460,14 +3461,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3522,14 +3523,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3858,7 +3859,7 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4033,7 +4034,7 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// some other error from OneDrive was returned - display what it is
|
// some other error from OneDrive was returned - display what it is
|
||||||
log.error("OneDrive generated an error when creating this path: ", path);
|
log.error("OneDrive generated an error when creating this path: ", path);
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4269,14 +4270,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4326,7 +4327,7 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4334,14 +4335,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4376,14 +4377,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4419,14 +4420,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4614,7 +4615,7 @@ final class SyncEngine
|
||||||
// error uploading file
|
// error uploading file
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4622,14 +4623,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4668,14 +4669,14 @@ final class SyncEngine
|
||||||
// error uploading file
|
// error uploading file
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4750,14 +4751,14 @@ final class SyncEngine
|
||||||
// error uploading file
|
// error uploading file
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4787,14 +4788,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4816,14 +4817,14 @@ final class SyncEngine
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (FileException e) {
|
} catch (FileException e) {
|
||||||
// display the error message
|
// display the error message
|
||||||
writeln("skipped.");
|
writeln("skipped.");
|
||||||
displayFileSystemErrorMessage(e.msg);
|
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||||
uploadFailed = true;
|
uploadFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4989,7 +4990,7 @@ final class SyncEngine
|
||||||
} catch (OneDriveException e) {
|
} catch (OneDriveException e) {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
log.vdebug("A further error was generated when attempting a reverse delete of objects from OneDrive");
|
log.vdebug("A further error was generated when attempting a reverse delete of objects from OneDrive");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5017,7 +5018,7 @@ final class SyncEngine
|
||||||
} catch (OneDriveException e) {
|
} catch (OneDriveException e) {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
log.vdebug("A further error was generated when attempting a reverse delete of objects from OneDrive");
|
log.vdebug("A further error was generated when attempting a reverse delete of objects from OneDrive");
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5025,7 +5026,7 @@ final class SyncEngine
|
||||||
// Not a 403 response & OneDrive Business Account / O365 Shared Folder / Library
|
// Not a 403 response & OneDrive Business Account / O365 Shared Folder / Library
|
||||||
log.vdebug("onedrive.deleteById generated an error response when attempting to delete object by item id");
|
log.vdebug("onedrive.deleteById generated an error response when attempting to delete object by item id");
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5107,34 +5108,6 @@ final class SyncEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse and display error message received from OneDrive
|
|
||||||
private void displayOneDriveErrorMessage(string message)
|
|
||||||
{
|
|
||||||
log.error("\nERROR: OneDrive returned an error with the following message:");
|
|
||||||
auto errorArray = splitLines(message);
|
|
||||||
log.error(" Error Message: ", errorArray[0]);
|
|
||||||
// extract 'message' as the reason
|
|
||||||
JSONValue errorMessage = parseJSON(replace(message, errorArray[0], ""));
|
|
||||||
string errorReason = errorMessage["error"]["message"].str;
|
|
||||||
// display reason
|
|
||||||
if (errorReason.startsWith("<!DOCTYPE")) {
|
|
||||||
// a HTML Error Reason was given
|
|
||||||
log.error(" Error Reason: A HTML Error response was provided. Use debug logging (--verbose --verbose) to view.");
|
|
||||||
log.vdebug(errorReason);
|
|
||||||
} else {
|
|
||||||
// a non HTML Error Reason was given
|
|
||||||
log.error(" Error Reason: ", errorReason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse and display error message received from the local file system
|
|
||||||
private void displayFileSystemErrorMessage(string message)
|
|
||||||
{
|
|
||||||
log.error("ERROR: The local file system returned an error with the following message:");
|
|
||||||
auto errorArray = splitLines(message);
|
|
||||||
log.error(" Error Message: ", errorArray[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_move
|
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_move
|
||||||
// This function is only called in monitor mode when an move event is coming from
|
// This function is only called in monitor mode when an move event is coming from
|
||||||
// inotify and we try to move the item.
|
// inotify and we try to move the item.
|
||||||
|
@ -5281,7 +5254,7 @@ final class SyncEngine
|
||||||
log.log(e.msg);
|
log.log(e.msg);
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5340,7 +5313,7 @@ final class SyncEngine
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5364,7 +5337,7 @@ final class SyncEngine
|
||||||
} catch (OneDriveException e) {
|
} catch (OneDriveException e) {
|
||||||
log.error("ERROR: Query of OneDrive for Office Site ID failed");
|
log.error("ERROR: Query of OneDrive for Office Site ID failed");
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5443,7 +5416,7 @@ final class SyncEngine
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5498,7 +5471,7 @@ final class SyncEngine
|
||||||
fileDetails = onedrive.getFileDetails(item.driveId, item.id);
|
fileDetails = onedrive.getFileDetails(item.driveId, item.id);
|
||||||
} catch (OneDriveException e) {
|
} catch (OneDriveException e) {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5564,7 +5537,7 @@ final class SyncEngine
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5621,10 +5594,10 @@ final class SyncEngine
|
||||||
// OneDrive threw an error
|
// OneDrive threw an error
|
||||||
log.vdebug("Error query: changes = onedrive.viewChangesById(driveId, idToQuery, deltaLink)");
|
log.vdebug("Error query: changes = onedrive.viewChangesById(driveId, idToQuery, deltaLink)");
|
||||||
log.vdebug("OneDrive threw an error when querying for these changes:");
|
log.vdebug("OneDrive threw an error when querying for these changes:");
|
||||||
log.vdebug("driveId: ", driveId);
|
log.vdebug("driveId: ", driveId);
|
||||||
log.vdebug("idToQuery: ", idToQuery);
|
log.vdebug("idToQuery: ", idToQuery);
|
||||||
log.vdebug("deltaLink: ", deltaLink);
|
log.vdebug("Previous deltaLink: ", deltaLink);
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5851,7 +5824,7 @@ final class SyncEngine
|
||||||
driveData = onedrive.getPathDetailsById(driveId, idToQuery);
|
driveData = onedrive.getPathDetailsById(driveId, idToQuery);
|
||||||
} else {
|
} else {
|
||||||
// There was a HTTP 5xx Server Side Error
|
// There was a HTTP 5xx Server Side Error
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
// Must exit here
|
// Must exit here
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -5879,7 +5852,7 @@ final class SyncEngine
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// There was a HTTP 5xx Server Side Error
|
// There was a HTTP 5xx Server Side Error
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
// Must exit here
|
// Must exit here
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -5923,7 +5896,7 @@ final class SyncEngine
|
||||||
// HTTP request returned status code 500 (Internal Server Error)
|
// HTTP request returned status code 500 (Internal Server Error)
|
||||||
if (e.httpStatusCode == 500) {
|
if (e.httpStatusCode == 500) {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTP request returned status code 504 (Gateway Timeout) or 429 retry
|
// HTTP request returned status code 504 (Gateway Timeout) or 429 retry
|
||||||
|
@ -5945,12 +5918,12 @@ final class SyncEngine
|
||||||
// display what the error is
|
// display what the error is
|
||||||
log.vdebug("Query Error: topLevelChildren = onedrive.listChildren(driveId, idToQuery, nextLink) on re-try after delay");
|
log.vdebug("Query Error: topLevelChildren = onedrive.listChildren(driveId, idToQuery, nextLink) on re-try after delay");
|
||||||
// error was not a 504 this time
|
// error was not a 504 this time
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Default operation if not 404, 410, 429, 500 or 504 errors
|
// Default operation if not 404, 410, 429, 500 or 504 errors
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6034,7 +6007,7 @@ final class SyncEngine
|
||||||
// HTTP request returned status code 500 (Internal Server Error)
|
// HTTP request returned status code 500 (Internal Server Error)
|
||||||
if (e.httpStatusCode == 500) {
|
if (e.httpStatusCode == 500) {
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTP request returned status code 504 (Gateway Timeout) or 429 retry
|
// HTTP request returned status code 504 (Gateway Timeout) or 429 retry
|
||||||
|
@ -6056,12 +6029,12 @@ final class SyncEngine
|
||||||
// display what the error is
|
// display what the error is
|
||||||
log.vdebug("Query Error: thisLevelChildren = onedrive.listChildren(driveId, idToQuery, nextLink) on re-try after delay");
|
log.vdebug("Query Error: thisLevelChildren = onedrive.listChildren(driveId, idToQuery, nextLink) on re-try after delay");
|
||||||
// error was not a 504 this time
|
// error was not a 504 this time
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Default operation if not 404, 410, 429, 500 or 504 errors
|
// Default operation if not 404, 410, 429, 500 or 504 errors
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
src/upload.d
15
src/upload.d
|
@ -211,7 +211,7 @@ struct UploadSession
|
||||||
// insert a new line as well, so that the below error is inserted on the console in the right location
|
// insert a new line as well, so that the below error is inserted on the console in the right location
|
||||||
log.vlog("\nFragment upload failed - received an exception response from OneDrive");
|
log.vlog("\nFragment upload failed - received an exception response from OneDrive");
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
// retry fragment upload in case error is transient
|
// retry fragment upload in case error is transient
|
||||||
log.vlog("Retrying fragment upload");
|
log.vlog("Retrying fragment upload");
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ struct UploadSession
|
||||||
// OneDrive threw another error on retry
|
// OneDrive threw another error on retry
|
||||||
log.vlog("Retry to upload fragment failed");
|
log.vlog("Retry to upload fragment failed");
|
||||||
// display what the error is
|
// display what the error is
|
||||||
displayOneDriveErrorMessage(e.msg);
|
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||||
// set response to null as the fragment upload was in error twice
|
// set response to null as the fragment upload was in error twice
|
||||||
response = null;
|
response = null;
|
||||||
}
|
}
|
||||||
|
@ -268,16 +268,7 @@ struct UploadSession
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse and display error message received from OneDrive
|
// save session details to temp file
|
||||||
private void displayOneDriveErrorMessage(string message) {
|
|
||||||
log.error("ERROR: OneDrive returned an error with the following message:");
|
|
||||||
auto errorArray = splitLines(message);
|
|
||||||
log.error(" Error Message: ", errorArray[0]);
|
|
||||||
// extract 'message' as the reason
|
|
||||||
JSONValue errorMessage = parseJSON(replace(message, errorArray[0], ""));
|
|
||||||
log.error(" Error Reason: ", errorMessage["error"]["message"].str);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void save()
|
private void save()
|
||||||
{
|
{
|
||||||
std.file.write(sessionFilePath, session.toString());
|
std.file.write(sessionFilePath, session.toString());
|
||||||
|
|
89
src/util.d
89
src/util.d
|
@ -11,6 +11,8 @@ import std.stdio;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.algorithm;
|
import std.algorithm;
|
||||||
import std.uri;
|
import std.uri;
|
||||||
|
import std.json;
|
||||||
|
import std.traits;
|
||||||
import qxor;
|
import qxor;
|
||||||
static import log;
|
static import log;
|
||||||
|
|
||||||
|
@ -247,6 +249,93 @@ bool containsASCIIHTMLCodes(string path)
|
||||||
return m.empty;
|
return m.empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse and display error message received from OneDrive
|
||||||
|
void displayOneDriveErrorMessage(string message, string callingFunction)
|
||||||
|
{
|
||||||
|
log.error("\nERROR: Microsoft OneDrive API returned an error with the following message:");
|
||||||
|
auto errorArray = splitLines(message);
|
||||||
|
log.error(" Error Message: ", errorArray[0]);
|
||||||
|
// Extract 'message' as the reason
|
||||||
|
JSONValue errorMessage = parseJSON(replace(message, errorArray[0], ""));
|
||||||
|
// extra debug
|
||||||
|
log.vdebug("Raw Error Data: ", message);
|
||||||
|
log.vdebug("JSON Message: ", errorMessage);
|
||||||
|
|
||||||
|
// What is the reason for the error
|
||||||
|
if (errorMessage.type() == JSONType.object) {
|
||||||
|
// configure the error reason
|
||||||
|
string errorReason;
|
||||||
|
string requestDate;
|
||||||
|
string requestId;
|
||||||
|
|
||||||
|
// set the reason for the error
|
||||||
|
try {
|
||||||
|
// Use error_description as reason
|
||||||
|
errorReason = errorMessage["error_description"].str;
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// we dont want to do anything here
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the reason for the error
|
||||||
|
try {
|
||||||
|
// Use ["error"]["message"] as reason
|
||||||
|
errorReason = errorMessage["error"]["message"].str;
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// we dont want to do anything here
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display the error reason
|
||||||
|
if (errorReason.startsWith("<!DOCTYPE")) {
|
||||||
|
// a HTML Error Reason was given
|
||||||
|
log.error(" Error Reason: A HTML Error response was provided. Use debug logging (--verbose --verbose) to view this error");
|
||||||
|
log.vdebug(errorReason);
|
||||||
|
} else {
|
||||||
|
// a non HTML Error Reason was given
|
||||||
|
log.error(" Error Reason: ", errorReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the date of request if available
|
||||||
|
try {
|
||||||
|
// Use ["error"]["innerError"]["date"] as date
|
||||||
|
requestDate = errorMessage["error"]["innerError"]["date"].str;
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// we dont want to do anything here
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the request-id if available
|
||||||
|
try {
|
||||||
|
// Use ["error"]["innerError"]["request-id"] as request-id
|
||||||
|
requestId = errorMessage["error"]["innerError"]["request-id"].str;
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// we dont want to do anything here
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display the date and request id if available
|
||||||
|
if (requestDate != "") log.error(" Error Timestamp: ", requestDate);
|
||||||
|
if (requestId != "") log.error(" API Request ID: ", requestId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where in the code was this error generated
|
||||||
|
log.error(" Calling Function: ", callingFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse and display error message received from the local file system
|
||||||
|
void displayFileSystemErrorMessage(string message, string callingFunction)
|
||||||
|
{
|
||||||
|
log.error("ERROR: The local file system returned an error with the following message:");
|
||||||
|
auto errorArray = splitLines(message);
|
||||||
|
// What was the error message
|
||||||
|
log.error(" Error Message: ", errorArray[0]);
|
||||||
|
// Where in the code was this error generated
|
||||||
|
log.error(" Calling Function: ", callingFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the function name that is being called to assist with identifying where an error is being generated
|
||||||
|
string getFunctionName(alias func)() {
|
||||||
|
return __traits(identifier, __traits(parent, func)) ~ "()\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unit Tests
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
assert(multiGlobMatch(".hidden", ".*"));
|
assert(multiGlobMatch(".hidden", ".*"));
|
||||||
|
|
Loading…
Reference in a new issue