diff options
author | Alexander Tkachev | 2019-08-25 14:30:21 +0700 |
---|---|---|
committer | Filippos Karapetis | 2019-08-25 12:15:14 +0300 |
commit | 5b5a89e3e7b880907f99675a68c5e0a8e2460470 (patch) | |
tree | 17f12e75c1da502d870cfd9313d44ee57055f56c /backends/cloud | |
parent | 24b1ec0dedf31097396741aa811dfabf9335b397 (diff) | |
download | scummvm-rg350-5b5a89e3e7b880907f99675a68c5e0a8e2460470.tar.gz scummvm-rg350-5b5a89e3e7b880907f99675a68c5e0a8e2460470.tar.bz2 scummvm-rg350-5b5a89e3e7b880907f99675a68c5e0a8e2460470.zip |
CLOUD: Make Network::ErrorResponse messages more verbose
This commit updates all usages of Network::ErrorResponse to specify at
least method name if not precise reason why operation failed.
Diffstat (limited to 'backends/cloud')
15 files changed, 36 insertions, 28 deletions
diff --git a/backends/cloud/box/boxlistdirectorybyidrequest.cpp b/backends/cloud/box/boxlistdirectorybyidrequest.cpp index 0258e3e1e9..c51c0f57c3 100644 --- a/backends/cloud/box/boxlistdirectorybyidrequest.cpp +++ b/backends/cloud/box/boxlistdirectorybyidrequest.cpp @@ -83,7 +83,7 @@ void BoxListDirectoryByIdRequest::responseCallback(Networking::JsonResponse resp if (response.request) _date = response.request->date(); - Networking::ErrorResponse error(this); + Networking::ErrorResponse error(this, "BoxListDirectoryByIdRequest::responseCallback: unknown error"); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); diff --git a/backends/cloud/box/boxtokenrefresher.cpp b/backends/cloud/box/boxtokenrefresher.cpp index 19cdd92667..db52672173 100644 --- a/backends/cloud/box/boxtokenrefresher.cpp +++ b/backends/cloud/box/boxtokenrefresher.cpp @@ -41,7 +41,7 @@ void BoxTokenRefresher::tokenRefreshed(Storage::BoolResponse response) { if (!response.value) { //failed to refresh token, notify user with NULL in original callback warning("BoxTokenRefresher: failed to refresh token"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "BoxTokenRefresher::tokenRefreshed: failed to refresh token", -1)); return; } diff --git a/backends/cloud/downloadrequest.cpp b/backends/cloud/downloadrequest.cpp index c07a23b671..994a9b3457 100644 --- a/backends/cloud/downloadrequest.cpp +++ b/backends/cloud/downloadrequest.cpp @@ -73,13 +73,13 @@ void DownloadRequest::streamErrorCallback(Networking::ErrorResponse error) { void DownloadRequest::handle() { if (!_localFile) { warning("DownloadRequest: no file to write"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "DownloadRequest::handle: no file to write into", -1)); return; } if (!_localFile->isOpen()) { warning("DownloadRequest: failed to open file to write"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "DownloadRequest::handle: failed to open file to write", -1)); return; } @@ -93,7 +93,7 @@ void DownloadRequest::handle() { if (readBytes != 0) if (_localFile->write(_buffer, readBytes) != readBytes) { warning("DownloadRequest: unable to write all received bytes into output file"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "DownloadRequest::handle: failed to write all bytes into a file", -1)); return; } @@ -113,7 +113,7 @@ void DownloadRequest::handle() { void DownloadRequest::restart() { warning("DownloadRequest: can't restart as there are no means to reopen DumpFile"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "DownloadRequest::restart: can't restart as there are no means to reopen DumpFile", -1)); //start(); } diff --git a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp index d6937d9cb2..e410f0a5c4 100644 --- a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp +++ b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp @@ -74,7 +74,7 @@ void DropboxCreateDirectoryRequest::responseCallback(Networking::JsonResponse re } if (response.request) _date = response.request->date(); - Networking::ErrorResponse error(this); + Networking::ErrorResponse error(this, "DropboxCreateDirectoryRequest::responseCallback: unknown error"); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); diff --git a/backends/cloud/dropbox/dropboxinforequest.cpp b/backends/cloud/dropbox/dropboxinforequest.cpp index ebf2d12170..08f5ca5223 100644 --- a/backends/cloud/dropbox/dropboxinforequest.cpp +++ b/backends/cloud/dropbox/dropboxinforequest.cpp @@ -71,7 +71,7 @@ void DropboxInfoRequest::userResponseCallback(Networking::JsonResponse response) return; } - Networking::ErrorResponse error(this); + Networking::ErrorResponse error(this, "DropboxInfoRequest::userResponseCallback: unknown error"); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); @@ -125,7 +125,7 @@ void DropboxInfoRequest::quotaResponseCallback(Networking::JsonResponse response return; } - Networking::ErrorResponse error(this); + Networking::ErrorResponse error(this, "DropboxInfoRequest::quotaResponseCallback: unknown error"); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); diff --git a/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp b/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp index 0b90ec6d2c..84a1918eff 100644 --- a/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp +++ b/backends/cloud/dropbox/dropboxlistdirectoryrequest.cpp @@ -84,7 +84,7 @@ void DropboxListDirectoryRequest::responseCallback(Networking::JsonResponse resp if (response.request) _date = response.request->date(); - Networking::ErrorResponse error(this); + Networking::ErrorResponse error(this, "DropboxListDirectoryRequest::responseCallback: unknown error"); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); diff --git a/backends/cloud/dropbox/dropboxuploadrequest.cpp b/backends/cloud/dropbox/dropboxuploadrequest.cpp index 361d8acd97..7330bae1fb 100644 --- a/backends/cloud/dropbox/dropboxuploadrequest.cpp +++ b/backends/cloud/dropbox/dropboxuploadrequest.cpp @@ -54,12 +54,12 @@ void DropboxUploadRequest::start() { _workingRequest->finish(); if (!_contentsStream) { warning("DropboxUploadRequest: cannot start because stream is invalid"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "DropboxUploadRequest::start: cannot start because stream is invalid", -1)); return; } if (!_contentsStream->seek(0)) { warning("DropboxUploadRequest: cannot restart because stream couldn't seek(0)"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "DropboxUploadRequest::start: cannot restart because stream couldn't seek(0)", -1)); return; } _ignoreCallback = false; diff --git a/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp b/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp index 24db75b077..caa6486f42 100644 --- a/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp +++ b/backends/cloud/googledrive/googledrivelistdirectorybyidrequest.cpp @@ -81,7 +81,7 @@ void GoogleDriveListDirectoryByIdRequest::responseCallback(Networking::JsonRespo if (response.request) _date = response.request->date(); - Networking::ErrorResponse error(this); + Networking::ErrorResponse error(this, "GoogleDriveListDirectoryByIdRequest::responseCallback"); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); diff --git a/backends/cloud/googledrive/googledrivetokenrefresher.cpp b/backends/cloud/googledrive/googledrivetokenrefresher.cpp index f28f73a788..c6c7ab60c1 100644 --- a/backends/cloud/googledrive/googledrivetokenrefresher.cpp +++ b/backends/cloud/googledrive/googledrivetokenrefresher.cpp @@ -41,7 +41,7 @@ void GoogleDriveTokenRefresher::tokenRefreshed(Storage::BoolResponse response) { if (!response.value) { //failed to refresh token, notify user with NULL in original callback warning("GoogleDriveTokenRefresher: failed to refresh token"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "GoogleDriveTokenRefresher::tokenRefreshed: failed to refresh token", -1)); return; } diff --git a/backends/cloud/googledrive/googledriveuploadrequest.cpp b/backends/cloud/googledrive/googledriveuploadrequest.cpp index c4728c5ac1..1a533e1360 100644 --- a/backends/cloud/googledrive/googledriveuploadrequest.cpp +++ b/backends/cloud/googledrive/googledriveuploadrequest.cpp @@ -55,7 +55,7 @@ void GoogleDriveUploadRequest::start() { _workingRequest->finish(); if (_contentsStream == nullptr || !_contentsStream->seek(0)) { warning("GoogleDriveUploadRequest: cannot restart because stream couldn't seek(0)"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "GoogleDriveUploadRequest::start: couldn't restart because failed to seek(0)", -1)); return; } _resolvedId = ""; //used to update file contents @@ -146,7 +146,7 @@ void GoogleDriveUploadRequest::startUploadCallback(Networking::JsonResponse resp if (_ignoreCallback) return; - Networking::ErrorResponse error(this, false, true, "", -1); + Networking::ErrorResponse error(this, false, true, "GoogleDriveUploadRequest::startUploadCallback", -1); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq) { const Networking::NetworkReadStream *stream = rq->getNetworkReadStream(); @@ -158,11 +158,19 @@ void GoogleDriveUploadRequest::startUploadCallback(Networking::JsonResponse resp _uploadUrl = headers["location"]; uploadNextPart(); return; + } else { + error.response += ": response must provide Location header, but it's not there"; } + } else { + error.response += ": response is not 200 OK"; } error.httpResponseCode = code; + } else { + error.response += ": missing response stream [improbable]"; } + } else { + error.response += ": missing request object [improbable]"; } Common::JSONValue *json = response.value; @@ -192,7 +200,7 @@ void GoogleDriveUploadRequest::uploadNextPart() { if (oldPos != _serverReceivedBytes) { if (!_contentsStream->seek(_serverReceivedBytes)) { warning("GoogleDriveUploadRequest: cannot upload because stream couldn't seek(%lu)", _serverReceivedBytes); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "GoogleDriveUploadRequest::uploadNextPart: seek() didn't work", -1)); return; } oldPos = _serverReceivedBytes; diff --git a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp index f7e995f332..e38d278559 100644 --- a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp +++ b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp @@ -96,7 +96,7 @@ void OneDriveCreateDirectoryRequest::responseCallback(Networking::JsonResponse r if (response.request) _date = response.request->date(); - Networking::ErrorResponse error(this); + Networking::ErrorResponse error(this, "OneDriveCreateDirectoryRequest::responseCallback: unknown error"); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); diff --git a/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp b/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp index f16097680b..0bf57a6317 100644 --- a/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp +++ b/backends/cloud/onedrive/onedrivelistdirectoryrequest.cpp @@ -102,7 +102,7 @@ void OneDriveListDirectoryRequest::listedDirectoryCallback(Networking::JsonRespo if (response.request) _date = response.request->date(); - Networking::ErrorResponse error(this); + Networking::ErrorResponse error(this, "OneDriveListDirectoryRequest::listedDirectoryCallback: unknown error"); Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request; if (rq && rq->getNetworkReadStream()) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); diff --git a/backends/cloud/onedrive/onedrivetokenrefresher.cpp b/backends/cloud/onedrive/onedrivetokenrefresher.cpp index 10992c5927..b456732233 100644 --- a/backends/cloud/onedrive/onedrivetokenrefresher.cpp +++ b/backends/cloud/onedrive/onedrivetokenrefresher.cpp @@ -41,7 +41,7 @@ void OneDriveTokenRefresher::tokenRefreshed(Storage::BoolResponse response) { if (!response.value) { //failed to refresh token, notify user with NULL in original callback warning("OneDriveTokenRefresher: failed to refresh token"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "OneDriveTokenRefresher::tokenRefreshed: failed to refresh token", -1)); return; } diff --git a/backends/cloud/onedrive/onedriveuploadrequest.cpp b/backends/cloud/onedrive/onedriveuploadrequest.cpp index 85e0525069..5e7011a6e9 100644 --- a/backends/cloud/onedrive/onedriveuploadrequest.cpp +++ b/backends/cloud/onedrive/onedriveuploadrequest.cpp @@ -56,12 +56,12 @@ void OneDriveUploadRequest::start() { _workingRequest->finish(); if (_contentsStream == nullptr) { warning("OneDriveUploadRequest: cannot restart because no stream given"); - finishError(Networking::ErrorResponse(this, false, true, "No stream given", -1)); + finishError(Networking::ErrorResponse(this, false, true, "OneDriveUploadRequest::start: can't restart, because no stream given", -1)); return; } if (!_contentsStream->seek(0)) { warning("OneDriveUploadRequest: cannot restart because stream couldn't seek(0)"); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "OneDriveUploadRequest::start: can't restart, because seek(0) didn't work", -1)); return; } _ignoreCallback = false; diff --git a/backends/cloud/savessyncrequest.cpp b/backends/cloud/savessyncrequest.cpp index b952d071e5..6e0efc55c1 100644 --- a/backends/cloud/savessyncrequest.cpp +++ b/backends/cloud/savessyncrequest.cpp @@ -72,7 +72,7 @@ void SavesSyncRequest::start() { new Common::Callback<SavesSyncRequest, Storage::ListDirectoryResponse>(this, &SavesSyncRequest::directoryListedCallback), new Common::Callback<SavesSyncRequest, Networking::ErrorResponse>(this, &SavesSyncRequest::directoryListedErrorCallback) ); - if (!_workingRequest) finishError(Networking::ErrorResponse(this)); + if (!_workingRequest) finishError(Networking::ErrorResponse(this, "SavesSyncRequest::start: Storage couldn't create Request to list directory")); } void SavesSyncRequest::directoryListedCallback(Storage::ListDirectoryResponse response) { @@ -235,7 +235,7 @@ void SavesSyncRequest::directoryListedErrorCallback(Networking::ErrorResponse er new Common::Callback<SavesSyncRequest, Networking::ErrorResponse>(this, &SavesSyncRequest::directoryCreatedErrorCallback) ); if (!_workingRequest) - finishError(Networking::ErrorResponse(this)); + finishError(Networking::ErrorResponse(this, "SavesSyncRequest::directoryListedErrorCallback: Storage couldn't create Request to create remote directory")); } void SavesSyncRequest::directoryCreatedCallback(Storage::BoolResponse response) { @@ -245,7 +245,7 @@ void SavesSyncRequest::directoryCreatedCallback(Storage::BoolResponse response) //stop syncing if failed to create saves directory if (!response.value) { - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "SavesSyncRequest::directoryCreatedCallback: failed to create remote directory", -1)); return; } @@ -284,7 +284,7 @@ void SavesSyncRequest::downloadNextFile() { new Common::Callback<SavesSyncRequest, Networking::ErrorResponse>(this, &SavesSyncRequest::fileDownloadedErrorCallback) ); if (!_workingRequest) - finishError(Networking::ErrorResponse(this)); + finishError(Networking::ErrorResponse(this, "SavesSyncRequest::downloadNextFile: Storage couldn't create Request to download a file")); } void SavesSyncRequest::fileDownloadedCallback(Storage::BoolResponse response) { @@ -296,7 +296,7 @@ void SavesSyncRequest::fileDownloadedCallback(Storage::BoolResponse response) { if (!response.value) { //delete the incomplete file g_system->getSavefileManager()->removeSavefile(_currentDownloadingFile.name()); - finishError(Networking::ErrorResponse(this, false, true, "", -1)); + finishError(Networking::ErrorResponse(this, false, true, "SavesSyncRequest::fileDownloadedCallback: failed to download a file", -1)); return; } @@ -343,7 +343,7 @@ void SavesSyncRequest::uploadNextFile() { new Common::Callback<SavesSyncRequest, Networking::ErrorResponse>(this, &SavesSyncRequest::fileUploadedErrorCallback) ); } - if (!_workingRequest) finishError(Networking::ErrorResponse(this)); + if (!_workingRequest) finishError(Networking::ErrorResponse(this, "SavesSyncRequest::uploadNextFile: Storage couldn't create Request to upload a file")); } void SavesSyncRequest::fileUploadedCallback(Storage::UploadResponse response) { |