aboutsummaryrefslogtreecommitdiffstats
path: root/sleekxmpp/exceptions.py
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2010-11-08 00:59:14 +0100
committerThibaut Horel <thibaut.horel@gmail.com>2010-11-08 00:59:14 +0100
commitb0a2a305028bf284fc5dcf7e1a696d85787f128f (patch)
treee6463e36e381b4342b7c864200a3482cca182618 /sleekxmpp/exceptions.py
parentb8499306ce329ca3881b1d1dfc3362a3a5c115d0 (diff)
downloadalias-b0a2a305028bf284fc5dcf7e1a696d85787f128f.tar.gz
Add the sleekxmpp library (will be added as a submodule later)
Diffstat (limited to 'sleekxmpp/exceptions.py')
-rw-r--r--sleekxmpp/exceptions.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/sleekxmpp/exceptions.py b/sleekxmpp/exceptions.py
new file mode 100644
index 0000000..d3988b4
--- /dev/null
+++ b/sleekxmpp/exceptions.py
@@ -0,0 +1,49 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+
+class XMPPError(Exception):
+
+ """
+ A generic exception that may be raised while processing an XMPP stanza
+ to indicate that an error response stanza should be sent.
+
+ The exception method for stanza objects extending RootStanza will create
+ an error stanza and initialize any additional substanzas using the
+ extension information included in the exception.
+
+ Meant for use in SleekXMPP plugins and applications using SleekXMPP.
+ """
+
+ def __init__(self, condition='undefined-condition', text=None, etype=None,
+ extension=None, extension_ns=None, extension_args=None):
+ """
+ Create a new XMPPError exception.
+
+ Extension information can be included to add additional XML elements
+ to the generated error stanza.
+
+ Arguments:
+ condition -- The XMPP defined error condition.
+ text -- Human readable text describing the error.
+ etype -- The XMPP error type, such as cancel or modify.
+ extension -- Tag name of the extension's XML content.
+ extension_ns -- XML namespace of the extensions' XML content.
+ extension_args -- Content and attributes for the extension
+ element. Same as the additional arguments to
+ the ET.Element constructor.
+ """
+ if extension_args is None:
+ extension_args = {}
+
+ self.condition = condition
+ self.text = text
+ self.etype = etype
+ self.extension = extension
+ self.extension_ns = extension_ns
+ self.extension_args = extension_args