example-bot: Add catchall except in decryption and encryption

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2019-02-23 18:29:54 +00:00
parent 9e70954a0e
commit 63dc98b07b

View file

@ -125,6 +125,9 @@ class EchoBot(ClientXMPP):
# resolve. At this point you should have seen other exceptions
# and given a chance to resolve them already.
await self.plain_reply(msg, 'I was not able to decrypt the message.')
except (Exception,) as exn:
await self.plain_reply(msg, 'An error occured while attempting decryption.\n%r' % exn)
raise
return None
@ -163,7 +166,11 @@ class EchoBot(ClientXMPP):
# This is where you prompt your user to ask what to do.
self['xep_0384'].trust(exn.bare_jid, exn.device, exn.ik)
except Exception as exn:
break
await self.plain_reply(
original_msg,
'An error occured while attempting to encrypt.\n%r' % exn,
)
raise
return None