Mercurial > libervia-web
comparison libervia/server/server.py @ 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 | b2d067339de3 |
comparison
equal
deleted
inserted
replaced
1203:251eba911d4d | 1204:a2df53dfbf46 |
---|---|
2318 | 2318 |
2319 self.waiting_profiles.setRequest(request, profile, register_with_ext_jid) | 2319 self.waiting_profiles.setRequest(request, profile, register_with_ext_jid) |
2320 try: | 2320 try: |
2321 connected = yield self.bridgeCall(connect_method, profile, password) | 2321 connected = yield self.bridgeCall(connect_method, profile, password) |
2322 except Exception as failure_: | 2322 except Exception as failure_: |
2323 fault = failure_.classname | 2323 fault = getattr(failure_, 'classname', None) |
2324 self.waiting_profiles.purgeRequest(profile) | 2324 self.waiting_profiles.purgeRequest(profile) |
2325 if fault in ("PasswordError", "ProfileUnknownError"): | 2325 if fault in ("PasswordError", "ProfileUnknownError"): |
2326 log.info(u"Profile {profile} doesn't exist or the submitted password is " | 2326 log.info(u"Profile {profile} doesn't exist or the submitted password is " |
2327 u"wrong".format( profile=profile)) | 2327 u"wrong".format( profile=profile)) |
2328 raise failure.Failure(ValueError(C.PROFILE_AUTH_ERROR)) | 2328 raise failure.Failure(ValueError(C.PROFILE_AUTH_ERROR)) |
2332 raise failure.Failure(ValueError(C.XMPP_AUTH_ERROR)) | 2332 raise failure.Failure(ValueError(C.XMPP_AUTH_ERROR)) |
2333 elif fault == "NoReply": | 2333 elif fault == "NoReply": |
2334 log.info(_(u"Did not receive a reply (the timeout expired or the " | 2334 log.info(_(u"Did not receive a reply (the timeout expired or the " |
2335 u"connection is broken)")) | 2335 u"connection is broken)")) |
2336 raise exceptions.TimeOutError | 2336 raise exceptions.TimeOutError |
2337 elif fault is None: | |
2338 log.info(_(u"Unexepected failure: {failure_}").format(failure_=failure)) | |
2339 raise failure_ | |
2337 else: | 2340 else: |
2338 log.error(u'Unmanaged fault class "{fault}" in errback for the ' | 2341 log.error(u'Unmanaged fault class "{fault}" in errback for the ' |
2339 u'connection of profile {profile}'.format( | 2342 u'connection of profile {profile}'.format( |
2340 fault=fault, profile=profile)) | 2343 fault=fault, profile=profile)) |
2341 raise failure.Failure(exceptions.InternalError(fault)) | 2344 raise failure.Failure(exceptions.InternalError(fault)) |