summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/dropbox_utils.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-05-11 20:12:46 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-05-11 20:12:46 +0000
commit488f93815d3c247376f038377e7bc3731b074231 (patch)
tree284f30d88e1b183792592c4066d9a7abe0bf6d81 /plugins/Dropbox/src/dropbox_utils.cpp
parentdb8cf4c1b0a624fd469c462e41a1e499ae808b70 (diff)
Dropbox: work commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@13556 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox/src/dropbox_utils.cpp')
-rw-r--r--plugins/Dropbox/src/dropbox_utils.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/plugins/Dropbox/src/dropbox_utils.cpp b/plugins/Dropbox/src/dropbox_utils.cpp
index 401ba75693..28eff5049f 100644
--- a/plugins/Dropbox/src/dropbox_utils.cpp
+++ b/plugins/Dropbox/src/dropbox_utils.cpp
@@ -1,42 +1,41 @@
#include "stdafx.h"
-wchar_t *CDropbox::HttpStatusToText(HTTP_STATUS status)
+char* CDropbox::HttpStatusToText(HTTP_STATUS status)
{
- switch (status) {
+ switch (status)
+ {
+ case HTTP_STATUS_ERROR:
+ return "Server does not respond";
case HTTP_STATUS_OK:
- return L"OK";
+ return "OK";
case HTTP_STATUS_BAD_REQUEST:
- return L"Bad input parameter. Error message should indicate which one and why";
+ return "Bad input parameter. Error message should indicate which one and why";
case HTTP_STATUS_UNAUTHORIZED:
- return L"Bad or expired token. This can happen if the user or Dropbox revoked or expired an access token. To fix, you should re-authenticate the user";
+ return "Bad or expired token. This can happen if the user or Dropbox revoked or expired an access token. To fix, you should re-authenticate the user";
case HTTP_STATUS_FORBIDDEN:
- return L"Bad OAuth request (wrong consumer key, bad nonce, expired timestamp...). Unfortunately, re-authenticating the user won't help here";
+ return "Bad OAuth request (wrong consumer key, bad nonce, expired timestamp...). Unfortunately, re-authenticating the user won't help here";
case HTTP_STATUS_NOT_FOUND:
- return L"File or folder not found at the specified path";
+ return "File or folder not found at the specified path";
case HTTP_STATUS_METHOD_NOT_ALLOWED:
- return L"Request method not expected (generally should be GET or POST)";
+ return "Request method not expected (generally should be GET or POST)";
case HTTP_STATUS_TOO_MANY_REQUESTS:
- return L"Your app is making too many requests and is being rate limited. 429s can trigger on a per-app or per-user basis";
+ return "Your app is making too many requests and is being rate limited. 429s can trigger on a per-app or per-user basis";
case HTTP_STATUS_SERVICE_UNAVAILABLE:
- return L"If the response includes the Retry-After header, this means your OAuth 1.0 app is being rate limited. Otherwise, this indicates a transient server error, and your app should retry its request.";
+ return "If the response includes the Retry-After header, this means your OAuth 1.0 app is being rate limited. Otherwise, this indicates a transient server error, and your app should retry its request.";
case HTTP_STATUS_INSUFICIENTE_STORAGE:
- return L"User is over Dropbox storage quota";
+ return "User is over Dropbox storage quota";
}
- return L"Unknown";
+ return "Unknown error";
}
-int CDropbox::HandleHttpResponseError(HANDLE hNetlibUser, NETLIBHTTPREQUEST *response)
-{
- if (!response) {
- Netlib_Logf(hNetlibUser, "%s: %s", MODULE, "Server does not respond");
- return ACKRESULT_FAILED;
- }
- if (response->resultCode != HTTP_STATUS_OK) {
- Netlib_Logf(hNetlibUser, "%s: %s", MODULE, HttpStatusToText((HTTP_STATUS)response->resultCode));
- return response->resultCode;
- }
- return 0;
+void CDropbox::HandleHttpResponseError(NETLIBHTTPREQUEST *response)
+{
+ if (response == NULL)
+ throw TransferException(HttpStatusToText(HTTP_STATUS_ERROR));
+
+ if (response->resultCode != HTTP_STATUS_OK)
+ throw TransferException(HttpStatusToText((HTTP_STATUS)response->resultCode));
}