[evolution-data-server] [ESoupSession] Special-case Daily Limit errors and propagate them to the caller



commit 0838b185312a2caa1ea87aef1717b286b3d7054d
Author: Milan Crha <mcrha redhat com>
Date:   Wed Oct 11 16:05:06 2017 +0200

    [ESoupSession] Special-case Daily Limit errors and propagate them to the caller
    
    The Google server returns 403 Forbidden when the error Daily Limit is exceeded,
    but this had not been propagated into the UI as in 3.24, only "403 Forbidden" had
    been shown, which is not enough for the issue recognition.

 src/libedataserver/e-soup-session.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/libedataserver/e-soup-session.c b/src/libedataserver/e-soup-session.c
index b247fb5..76907c3 100644
--- a/src/libedataserver/e-soup-session.c
+++ b/src/libedataserver/e-soup-session.c
@@ -998,6 +998,25 @@ e_soup_session_send_request_sync (ESoupSession *session,
                e_soup_session_extract_ssl_data (session, message);
 
                g_clear_object (&message);
+       } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_FORBIDDEN)) {
+               message = soup_request_http_get_message (request);
+
+               if (message && message->response_body &&
+                   message->response_body->data && message->response_body->length) {
+                       gchar *body = g_strndup (message->response_body->data, 
message->response_body->length);
+
+                       /* Do not localize this string, it is returned by the server. */
+                       if (body && (e_util_strstrcase (body, "Daily Limit") ||
+                           e_util_strstrcase (body, "https://console.developers.google.com/";))) {
+                               /* Special-case this condition and provide this error up to the UI. */
+                               g_set_error_literal (error, local_error->domain, local_error->code, body);
+                               g_clear_error (&local_error);
+                       }
+
+                       g_free (body);
+               }
+
+               g_clear_object (&message);
        }
 
        if (local_error)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]