[geary/wip/misc-warning-fixes: 2/2] Fix unhandled error warning, tidy up error handling



commit 018f700d0dfbedb3de5f1f7397d4c365c436c82e
Author: Michael Gratton <mike vee net>
Date:   Thu Jan 10 23:09:36 2019 +1100

    Fix unhandled error warning, tidy up error handling

 src/engine/imap/api/imap-client-service.vala | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/engine/imap/api/imap-client-service.vala b/src/engine/imap/api/imap-client-service.vala
index ab26ad02..ff854815 100644
--- a/src/engine/imap/api/imap-client-service.vala
+++ b/src/engine/imap/api/imap-client-service.vala
@@ -296,20 +296,29 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
             // Nothing to do here
         } catch (GLib.Error err) {
             Geary.ErrorContext context = new Geary.ErrorContext(err);
-            debug("[%s] Error adding new session to the pool: %s",
+            debug("[%s] Error creating new session for the pool: %s",
                   this.account.id, context.format_full_error());
-            notify_connection_failed(new ErrorContext(err));
+            notify_connection_failed(context);
         }
 
-        if (new_session != null) {
-            notify_connected();
-            yield this.sessions_mutex.execute_locked(() => {
-                    this.all_sessions.add(new_session);
-                });
-            this.free_queue.send(new_session);
-        } else {
+        if (new_session == null) {
             // An error was thrown, so close the pool
             this.close_pool.begin();
+        } else {
+            try {
+                yield this.sessions_mutex.execute_locked(() => {
+                        this.all_sessions.add(new_session);
+                    });
+                this.free_queue.send(new_session);
+                notify_connected();
+            } catch (GLib.Error err) {
+                Geary.ErrorContext context = new Geary.ErrorContext(err);
+                debug("[%s] Error adding new session to the pool: %s",
+                      this.account.id, context.format_full_error());
+                notify_connection_failed(context);
+                new_session.disconnect_async.begin(null);
+                this.close_pool.begin();
+            }
         }
     }
 


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