# HG changeset patch
# User Goffi <goffi@goffi.org>
# Date 1563108511 -7200
# Node ID a2df53dfbf465811bc402fb7d9f258beba2acdd6
# Parent  251eba911d4d8405f30f74efa9b937bc5e1535cb
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.

diff -r 251eba911d4d -r a2df53dfbf46 libervia/server/server.py
--- 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(