diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2015-08-08 15:43:54 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2015-08-08 17:34:06 +0200 |
commit | 1b4187fa5602d0074b6b0873fb1dd2f98779b637 (patch) | |
tree | 0eb618676f5c178365b919cb707ec6102f9b91f8 | |
parent | cf7a60705ea1004011f2f911b767ee1a862e014a (diff) | |
download | slixmpp-1b4187fa5602d0074b6b0873fb1dd2f98779b637.tar.gz slixmpp-1b4187fa5602d0074b6b0873fb1dd2f98779b637.tar.bz2 slixmpp-1b4187fa5602d0074b6b0873fb1dd2f98779b637.tar.xz slixmpp-1b4187fa5602d0074b6b0873fb1dd2f98779b637.zip |
Add a format() method to XMPPError which returns a readable string.
-rw-r--r-- | slixmpp/exceptions.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/slixmpp/exceptions.py b/slixmpp/exceptions.py index 94bbf202..a6c09a0b 100644 --- a/slixmpp/exceptions.py +++ b/slixmpp/exceptions.py @@ -56,6 +56,18 @@ class XMPPError(Exception): self.extension_ns = extension_ns self.extension_args = extension_args + def format(self): + """ + Format the error in a simple user-readable string. + """ + text = [self.etype, self.condition] + if self.text: + text.append(self.text) + if self.extension: + text.append(self.extension) + # TODO: handle self.extension_args + return ': '.join(text) + class IqTimeout(XMPPError): |