From fc6e2d9cfe83d0c2975cfa928b60933e52298f90 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Wed, 12 Feb 2020 06:16:38 +1100 Subject: [PATCH] Catch 429 HTTPS return code when query for oneDriveRootDetails fails (#796) * Catch 429 HTTPS return code when query for oneDriveRootDetails fails & provide error feedback that this was the reason why application initialization failed --- src/sync.d | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/sync.d b/src/sync.d index 0da06960..cb338495 100644 --- a/src/sync.d +++ b/src/sync.d @@ -291,6 +291,13 @@ final class SyncEngine // Must exit here exit(-1); } + if (e.httpStatusCode == 429) { + // HTTP request returned status code 429 (Too Many Requests) + log.error("\nERROR: OneDrive returned a 'HTTP 429 - Too Many Requests' - Cannot Initialize Sync Engine"); + log.error("ERROR: Please try to access OneDrive again later\n"); + // Must exit here + exit(-1); + } if (e.httpStatusCode >= 500) { // There was a HTTP 5xx Server Side Error log.error("ERROR: OneDrive returned a 'HTTP 5xx Server Side Error' - Cannot Initialize Sync Engine"); @@ -320,6 +327,13 @@ final class SyncEngine // Must exit here exit(-1); } + if (e.httpStatusCode == 429) { + // HTTP request returned status code 429 (Too Many Requests) + log.error("\nERROR: OneDrive returned a 'HTTP 429 - Too Many Requests' - Cannot Initialize Sync Engine"); + log.error("ERROR: Please try to access OneDrive again later\n"); + // Must exit here + exit(-1); + } if (e.httpStatusCode >= 500) { // There was a HTTP 5xx Server Side Error log.error("ERROR: OneDrive returned a 'HTTP 5xx Server Side Error' - Cannot Initialize Sync Engine"); @@ -376,6 +390,9 @@ final class SyncEngine initDone = false; // log why log.error("ERROR: Unable to query OneDrive to initialize application"); + // Debug OneDrive Account details response + log.vdebug("OneDrive Account Details: ", oneDriveDetails); + log.vdebug("OneDrive Account Root Details: ", oneDriveRootDetails); // Must exit here exit(-1); }