[geary/wip/713006-better-error-reporting: 5/6] Clean up SmtpOutboxFolder error handling further.



commit 5382752fb88372241f56bfef5c998c03f7e47daf
Author: Michael James Gratton <mike vee net>
Date:   Thu Nov 9 17:57:44 2017 +1100

    Clean up SmtpOutboxFolder error handling further.
    
    * src/engine/api/geary-account.vala (Account.Problem): Remove
      SEND_EMAIL_DELIVERY_FAILURE, we can't really and don't want to
      distinguish between and general sending failures. Remove uses.
    
    * src/engine/imap-db/outbox/smtp-outbox-folder.vala (SmtpOutboxFolder):
      Use new global auth retry constant.
      (SmtpOutboxFolder::postman_send): Always throw auth error when we hit
      max attempts, always throw non-TLS errors so we don't keep on blindly
      retrying.

 src/client/application/geary-controller.vala      |    4 ---
 src/engine/api/geary-account.vala                 |    2 +-
 src/engine/imap-db/outbox/smtp-outbox-folder.vala |   30 ++++++++++++---------
 3 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 5cecdcf..365ce7b 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -891,10 +891,6 @@ public class GearyController : Geary.BaseObject {
             this.main_window.show_infobar(info_bar);
             break;
 
-        case Geary.Account.Problem.SEND_EMAIL_DELIVERY_FAILURE:
-            handle_outbox_failure(StatusBar.Message.OUTBOX_SEND_FAILURE);
-            break;
-
         case Geary.Account.Problem.SEND_EMAIL_SAVE_FAILED:
             handle_outbox_failure(StatusBar.Message.OUTBOX_SAVE_SENT_MAIL_FAILED);
             break;
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index 2655831..ffc16a4 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -34,12 +34,12 @@ public abstract class Geary.Account : BaseObject {
         NETWORK_UNAVAILABLE,
         RECV_EMAIL_ERROR,
         RECV_EMAIL_LOGIN_FAILED,
-        SEND_EMAIL_DELIVERY_FAILURE,
         SEND_EMAIL_ERROR,
         SEND_EMAIL_LOGIN_FAILED,
         SEND_EMAIL_SAVE_FAILED,
     }
 
+
     public Geary.AccountInformation information { get; protected set; }
     
     public Geary.ProgressMonitor search_upgrade_monitor { get; protected set; }
diff --git a/src/engine/imap-db/outbox/smtp-outbox-folder.vala 
b/src/engine/imap-db/outbox/smtp-outbox-folder.vala
index c991a2a..e582176 100644
--- a/src/engine/imap-db/outbox/smtp-outbox-folder.vala
+++ b/src/engine/imap-db/outbox/smtp-outbox-folder.vala
@@ -25,9 +25,6 @@ private class Geary.SmtpOutboxFolder :
     // loaded, connections to settle, pigs to fly, etc.
     private const uint START_TIMEOUT = 4;
 
-    // Number of times to retry sending after auth failures
-    private const uint AUTH_ERROR_MAX_RETRY = 3;
-
 
     private class OutboxRow {
         public int64 id;
@@ -481,8 +478,8 @@ private class Geary.SmtpOutboxFolder :
             // We immediately retry auth errors after the prompting
             // the user, but if they get it wrong enough times or
             // cancel we have no choice other than to stop the postman
-            int attempts = 0;
-            while (!mail_sent && ++attempts <= AUTH_ERROR_MAX_RETRY) {
+            uint attempts = 0;
+            while (!mail_sent && ++attempts <= Geary.Account.AUTH_ATTEMPTS_MAX) {
                 try {
                     debug("Outbox postman: Sending \"%s\" (ID:%s)...",
                           message_subject(message), row.outbox_id.to_string());
@@ -491,8 +488,14 @@ private class Geary.SmtpOutboxFolder :
                 } catch (Error send_err) {
                     debug("Outbox postman send error: %s", send_err.message);
                     if (send_err is SmtpError.AUTHENTICATION_FAILED) {
-                        // At this point we may already have a password in memory -- but it's incorrect.
-                        // Delete the current password, prompt the user for a new one, and try again.
+                        if (attempts == Geary.Account.AUTH_ATTEMPTS_MAX) {
+                            throw send_err;
+                        }
+
+                        // At this point we may already have a
+                        // password in memory -- but it's incorrect.
+                        // Delete the current password, prompt the
+                        // user for a new one, and try again.
                         bool user_confirmed = false;
                         try {
                             user_confirmed = yield account.fetch_passwords_async(
@@ -503,18 +506,19 @@ private class Geary.SmtpOutboxFolder :
                         }
 
                         if (!user_confirmed) {
-                            // The user cancelled hence they don't
-                            // want to be prompted again, so report it
-                            // and bail out.
+                            // The user cancelled and hence they don't
+                            // want to be prompted again, so bail out.
                             throw send_err;
                         }
                     } else if (send_err is TlsError) {
-                        // up to application to be aware of problem via Geary.Engine, but do nap and
-                        // try later
+                        // up to application to be aware of problem
+                        // via Geary.Engine, but do nap and try later
                         debug("TLS connection warnings connecting to %s, user must confirm connection to 
continue",
                               this.smtp_endpoint.to_string());
+                        break;
                     } else {
-                        report_problem(Geary.Account.Problem.SEND_EMAIL_DELIVERY_FAILURE, send_err);
+                        // not much else we can do - just bail out
+                        throw send_err;
                     }
                 }
             }


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