Enabling logging to raise exceptions, hardening my exception handling, and tracking...
authorEd Page <eopage@byu.net>
Tue, 20 Apr 2010 02:27:52 +0000 (21:27 -0500)
committerEd Page <eopage@byu.net>
Tue, 20 Apr 2010 02:27:52 +0000 (21:27 -0500)
src/channel/call.py
src/channel/debug_prompt.py
src/connection.py
src/gvoice/addressbook.py
src/gvoice/conversations.py
src/theonering.py
src/util/go_utils.py

index 0fd08ea..aefc598 100644 (file)
@@ -186,7 +186,7 @@ class CallChannel(
                                {},
                        )
                except Exception:
-                       _moduleLogger.exception(result)
+                       _moduleLogger.exception("While placing call to %s" % (self.__calledNumber, ))
                        return
 
                self._delayedClose.start(seconds=0)
@@ -202,7 +202,7 @@ class CallChannel(
                                {},
                        )
                except Exception:
-                       _moduleLogger.exception(result)
+                       _moduleLogger.exception("While canceling a call to %s" % (self.__calledNumber, ))
                        return
 
        @misc_utils.log_exception(_moduleLogger)
index 47a31dd..545f952 100644 (file)
@@ -166,6 +166,7 @@ class DebugPromptChannel(tp.ChannelTypeText, cmd.Cmd):
                        self._report_new_message(str(isAuthed))
                except Exception, e:
                        self._report_new_message(str(e))
+                       return
 
        def help_is_authed(self):
                self._report_new_message("Print whether logged in to Google Voice")
@@ -189,6 +190,7 @@ class DebugPromptChannel(tp.ChannelTypeText, cmd.Cmd):
                        self._report_new_message(str(isDnd))
                except Exception, e:
                        self._report_new_message(str(e))
+                       return
 
        def help_is_dnd(self):
                self._report_new_message("Print whether Do-Not-Disturb mode enabled on the Google Voice account")
index 96808cb..4ade96e 100644 (file)
@@ -235,7 +235,9 @@ class TheOneRingConnection(
        @misc_utils.log_exception(_moduleLogger)
        def _on_login_error(self, error):
                _moduleLogger.error(error)
-               if isinstance(error, gvoice.backend.NetworkError):
+               if isinstance(error, StopIteration):
+                       pass
+               elif isinstance(error, gvoice.backend.NetworkError):
                        self.disconnect(telepathy.CONNECTION_STATUS_REASON_NETWORK_ERROR)
                else:
                        self.disconnect(telepathy.CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED)
index 2a5e389..9d241cf 100644 (file)
@@ -32,11 +32,15 @@ class Addressbook(object):
 
        @misc_utils.log_exception(_moduleLogger)
        def _update(self):
-               contacts = yield (
-                       self._backend.get_contacts,
-                       (),
-                       {},
-               )
+               try:
+                       contacts = yield (
+                               self._backend.get_contacts,
+                               (),
+                               {},
+                       )
+               except Exception:
+                       _moduleLogger.exception("While updating the addressbook")
+                       return
 
                oldContacts = self._numbers
                oldContactNumbers = set(self.get_numbers())
index 2b7df61..b48887e 100644 (file)
@@ -96,11 +96,15 @@ class Conversations(object):
 
        @misc_utils.log_exception(_moduleLogger)
        def _update(self):
-               conversationResult = yield (
-                       self._get_raw_conversations,
-                       (),
-                       {},
-               )
+               try:
+                       conversationResult = yield (
+                               self._get_raw_conversations,
+                               (),
+                               {},
+                       )
+               except Exception:
+                       _moduleLogger.exception("%s While updating conversations" % (self._name, ))
+                       return
 
                oldConversationIds = set(self._conversations.iterkeys())
 
index 49a173f..bc8a6cf 100755 (executable)
@@ -91,6 +91,7 @@ def main(logToFile):
 
        telepathy_utils.debug_divert_messages(os.getenv('THEONERING_LOGFILE'))
        logFormat = '(%(asctime)s) %(levelname)-5s %(threadName)s.%(name)s: %(message)s'
+       logging.raiseExceptions = True # Getting funky shutdown behavior, checking it out
        if logToFile:
                logging.basicConfig(
                        level=logging.DEBUG,
index 52ccf92..20ccac1 100644 (file)
@@ -169,7 +169,6 @@ class AsyncPool(object):
                        callback(result)
                except Exception:
                        _moduleLogger.exception("Callback errored")
-                       pass
                return False
 
        @misc.log_exception(_moduleLogger)
@@ -190,6 +189,7 @@ class AsyncPool(object):
                        self.__workQueue.task_done()
 
                        gobject.idle_add(self.__trampoline_callback, on_success, on_error, isError, result)
+               _moduleLogger.debug("Shutting down worker thread")
 
 
 class AsyncLinearExecution(object):