/usr/share/pyshared/pyxmpp/exceptions.py is in python-pyxmpp 1.1.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | #
# (C) Copyright 2003-2010 Jacek Konieczny <jajcus@jajcus.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License Version
# 2.1 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
"""PyXMPP exceptions.
This module defines all exceptions raised by PyXMPP.
"""
__docformat__="restructuredtext en"
import logging
class Error(StandardError):
"""Base class for all PyXMPP exceptions."""
pass
class JIDError(Error, ValueError):
"Exception raised when invalid JID is used"
pass
class StreamError(Error):
"""Base class for all stream errors."""
pass
class StreamEncryptionRequired(StreamError):
"""Exception raised when stream encryption is requested, but not used."""
pass
class HostMismatch(StreamError):
"""Exception raised when the connected host name is other then requested."""
pass
class FatalStreamError(StreamError):
"""Base class for all fatal Stream exceptions.
When `FatalStreamError` is raised the stream is no longer usable."""
pass
class StreamParseError(FatalStreamError):
"""Raised when invalid XML is received in an XMPP stream."""
pass
class DNSError(FatalStreamError):
"""Raised when no host name could be resolved for the target."""
pass
class UnexpectedCNAMEError(DNSError):
"""Raised when CNAME record was found when A or AAAA was expected."""
pass
class StreamAuthenticationError(FatalStreamError):
"""Raised when stream authentication fails."""
pass
class TLSNegotiationFailed(FatalStreamError):
"""Raised when stream TLS negotiation fails."""
pass
class TLSError(FatalStreamError):
"""Raised on TLS error during stream processing."""
pass
class TLSNegotiatedButNotAvailableError(TLSError):
"""Raised on TLS error during stream processing."""
pass
class SASLNotAvailable(StreamAuthenticationError):
"""Raised when SASL authentication is requested, but not available."""
pass
class SASLMechanismNotAvailable(StreamAuthenticationError):
"""Raised when none of SASL authentication mechanisms requested is
available."""
pass
class SASLAuthenticationFailed(StreamAuthenticationError):
"""Raised when stream SASL authentication fails."""
pass
class StringprepError(Error):
"""Exception raised when string preparation results in error."""
pass
class ClientError(Error):
"""Raised on a client error."""
pass
class FatalClientError(ClientError):
"""Raised on a fatal client error."""
pass
class ClientStreamError(StreamError):
"""Raised on a client stream error."""
pass
class FatalClientStreamError(FatalStreamError):
"""Raised on a fatal client stream error."""
pass
class LegacyAuthenticationError(ClientStreamError):
"""Raised on a legacy authentication error."""
pass
class RegistrationError(ClientStreamError):
"""Raised on a in-band registration error."""
pass
class ComponentStreamError(StreamError):
"""Raised on a component error."""
pass
class FatalComponentStreamError(ComponentStreamError,FatalStreamError):
"""Raised on a fatal component error."""
pass
########################
# Protocol Errors
class ProtocolError(Error):
"""Raised when there is something wrong with a stanza processed.
When not processed earlier by an application, the exception will be catched
by the stanza dispatcher to return XMPP error to the stanza sender, when
allowed.
ProtocolErrors handled internally by PyXMPP will be logged via the logging
interface. Errors reported to the sender will be logged using
"pyxmpp.ProtocolError.reported" channel and the ignored errors using
"pyxmpp.ProtocolError.ignored" channel. Both with the "debug" level.
:Ivariables:
- `xmpp_name` -- XMPP error name which should be reported.
- `message` -- the error message."""
logger_reported = logging.getLogger("pyxmpp.ProtocolError.reported")
logger_ignored = logging.getLogger("pyxmpp.ProtocolError.ignored")
def __init__(self, xmpp_name, message):
self.args = (xmpp_name, message)
@property
def xmpp_name(self):
return self.args[0]
@property
def message(self):
return self.args[1]
def log_reported(self):
self.logger_reported.debug(u"Protocol error detected: %s", self.message)
def log_ignored(self):
self.logger_ignored.debug(u"Protocol error detected: %s", self.message)
def __unicode__(self):
return str(self.args[1])
def __repr__(self):
return "<ProtocolError %r %r>" % (self.xmpp_name, self.message)
class BadRequestProtocolError(ProtocolError):
"""Raised when invalid stanza is processed and 'bad-request' error should be reported."""
def __init__(self, message):
ProtocolError.__init__(self, "bad-request", message)
class JIDMalformedProtocolError(ProtocolError, JIDError):
"""Raised when invalid JID is encountered."""
def __init__(self, message):
ProtocolError.__init__(self, "jid-malformed", message)
class FeatureNotImplementedProtocolError(ProtocolError):
"""Raised when stanza requests a feature which is not (yet) implemented."""
def __init__(self, message):
ProtocolError.__init__(self, "feature-not-implemented", message)
# vi: sts=4 et sw=4
|