summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2022-03-23 16:10:05 +0100
committerMaxime “pep” Buquet <pep@bouah.net>2022-03-23 16:10:05 +0100
commite010abcd95e88b4b76326ce2bd8e793506df7fb2 (patch)
tree030b44693d000dd1b2a526f719bdacd94720287a /plugins
parentdef167791d099ffecb5a4b5a5582dce99e319987 (diff)
downloadpoezio-e010abcd95e88b4b76326ce2bd8e793506df7fb2.tar.gz
poezio-e010abcd95e88b4b76326ce2bd8e793506df7fb2.tar.bz2
poezio-e010abcd95e88b4b76326ce2bd8e793506df7fb2.tar.xz
poezio-e010abcd95e88b4b76326ce2bd8e793506df7fb2.zip
plugins/contact: Move error handling where the error actually happens
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/contact.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/plugins/contact.py b/plugins/contact.py
index a3a0514b..070fbe4c 100644
--- a/plugins/contact.py
+++ b/plugins/contact.py
@@ -13,6 +13,7 @@ Usage
"""
from poezio.plugin import BasePlugin
+from slixmpp.exceptions import IqError, IqTimeout
from slixmpp.jid import InvalidJID
CONTACT_TYPES = ['abuse', 'admin', 'feedback', 'sales', 'security', 'support']
@@ -25,12 +26,6 @@ class Plugin(BasePlugin):
help='Get the Contact Addresses of a JID')
def on_disco(self, iq):
- if iq['type'] == 'error':
- error_condition = iq['error']['condition']
- error_text = iq['error']['text']
- message = 'Error getting Contact Addresses from %s: %s: %s' % (iq['from'], error_condition, error_text)
- self.api.information(message, 'Error')
- return
info = iq['disco_info']
contacts = []
# iterate all data forms, in case there are multiple
@@ -57,3 +52,9 @@ class Plugin(BasePlugin):
self.on_disco(iq)
except InvalidJID as e:
self.api.information('Invalid JID “%s”: %s' % (jid, e), 'Error')
+ except (IqError, IqTimeout,) as exn:
+ ifrom = exn.iq['from']
+ condition = exn.iq['error']['condition']
+ text = exn.iq['error']['text']
+ message = f'Error getting Contact Addresses from {ifrom}: {condition}: {text}'
+ self.api.information(message, 'Error')