From ff2e1835d2b749c9a37211d8d1ec83de96ba83fc Mon Sep 17 00:00:00 2001 From: "Schimon Jehudah, Adv." Date: Tue, 19 Nov 2024 12:11:10 +0200 Subject: [PATCH] Add timeout exception and general exceptions. (Thank you. mirux.) --- kaikout/xmpp/muc.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/kaikout/xmpp/muc.py b/kaikout/xmpp/muc.py index e97e82f..6b6447f 100644 --- a/kaikout/xmpp/muc.py +++ b/kaikout/xmpp/muc.py @@ -16,6 +16,7 @@ FIXME 1) Save name of groupchat instead of jid as name """ +from asyncio import TimeoutError from slixmpp.exceptions import IqError, IqTimeout, PresenceError from kaikout.log import Logger @@ -143,6 +144,11 @@ class XmppMuc: logger.error(str(e)) logger.error(jid) result = 'timeout' + except TimeoutError as e: + logger.error('Timeout AsyncIO') + logger.error(str(e)) + logger.error(jid) + result = 'timeout' except PresenceError as e: logger.error('Error Presence') logger.error(str(e)) @@ -152,6 +158,11 @@ class XmppMuc: result = 'ban' else: result = 'error' + except Exception as e: + logger.error('Unknown error') + logger.error(str(e)) + logger.error(jid) + result = 'unknown' return result @@ -183,6 +194,11 @@ class XmppMuc: logger.error('Could not set affiliation at room: {}'.format(room)) logger.error(str(e)) logger.error(room) + except Exception as e: + logger.error('Unknown error') + logger.error('Could not set affiliation at room: {}'.format(room)) + logger.error(str(e)) + logger.error(room) async def set_role(self, room, alias, role, reason=None): @@ -195,3 +211,8 @@ class XmppMuc: logger.error('Could not set role of alias: {}'.format(alias)) logger.error(str(e)) logger.error(room) + except Exception as e: + logger.error('Unknown error') + logger.error('Could not set role of alias: {}'.format(alias)) + logger.error(str(e)) + logger.error(room)