changeset 1204:a2df53dfbf46

server: handle unexpected exceptions on connect: `classname` attribute was used on exceptions while it may not exists with some of them. This patch fixes this by showing a warning and re-raising the exception when this case happens.
author Goffi <goffi@goffi.org>
date Sun, 14 Jul 2019 14:48:31 +0200
parents 251eba911d4d
children 92d0a2b785fd
files libervia/server/server.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/server/server.py	Sun Jul 14 14:45:51 2019 +0200
+++ b/libervia/server/server.py	Sun Jul 14 14:48:31 2019 +0200
@@ -2320,7 +2320,7 @@
         try:
             connected = yield self.bridgeCall(connect_method, profile, password)
         except Exception as failure_:
-            fault = failure_.classname
+            fault = getattr(failure_, 'classname', None)
             self.waiting_profiles.purgeRequest(profile)
             if fault in ("PasswordError", "ProfileUnknownError"):
                 log.info(u"Profile {profile} doesn't exist or the submitted password is "
@@ -2334,6 +2334,9 @@
                 log.info(_(u"Did not receive a reply (the timeout expired or the "
                            u"connection is broken)"))
                 raise exceptions.TimeOutError
+            elif fault is None:
+                log.info(_(u"Unexepected failure: {failure_}").format(failure_=failure))
+                raise failure_
             else:
                 log.error(u'Unmanaged fault class "{fault}" in errback for the '
                           u'connection of profile {profile}'.format(