/usr/lib/python2.7/dist-packages/autobahn/wamp/exception.py is in python-autobahn 17.10.1+dfsg1-2.
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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | ###############################################################################
#
# The MIT License (MIT)
#
# Copyright (c) Crossbar.io Technologies GmbH
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
###############################################################################
from __future__ import absolute_import
import six
from autobahn.util import public
from autobahn.wamp.uri import error
__all__ = (
'Error',
'SessionNotReady',
'SerializationError',
'ProtocolError',
'TransportLost',
'ApplicationError',
'NotAuthorized',
'InvalidUri',
)
@public
class Error(RuntimeError):
"""
Base class for all exceptions related to WAMP.
"""
@public
class SessionNotReady(Error):
"""
The application tried to perform a WAMP interaction, but the
session is not yet fully established.
"""
@public
class SerializationError(Error):
"""
Exception raised when the WAMP serializer could not serialize the
application payload (``args`` or ``kwargs`` for ``CALL``, ``PUBLISH``, etc).
"""
@public
class ProtocolError(Error):
"""
Exception raised when WAMP protocol was violated. Protocol errors
are fatal and are handled by the WAMP implementation. They are
not supposed to be handled at the application level.
"""
@public
class TransportLost(Error):
"""
Exception raised when the transport underlying the WAMP session
was lost or is not connected.
"""
@public
class ApplicationError(Error):
"""
Base class for all exceptions that can/may be handled
at the application level.
"""
INVALID_URI = u"wamp.error.invalid_uri"
"""
Peer provided an incorrect URI for a URI-based attribute of a WAMP message
such as a realm, topic or procedure.
"""
INVALID_PAYLOAD = u"wamp.error.invalid_payload"
"""
The application payload could not be serialized.
"""
NO_SUCH_PROCEDURE = u"wamp.error.no_such_procedure"
"""
A Dealer could not perform a call, since not procedure is currently registered
under the given URI.
"""
PROCEDURE_ALREADY_EXISTS = u"wamp.error.procedure_already_exists"
"""
A procedure could not be registered, since a procedure with the given URI is
already registered.
"""
PROCEDURE_EXISTS_INVOCATION_POLICY_CONFLICT = u"wamp.error.procedure_exists_with_different_invocation_policy"
"""
A procedure could not be registered, since a procedure with the given URI is
already registered, and the registration has a conflicting invocation policy.
"""
NO_SUCH_REGISTRATION = u"wamp.error.no_such_registration"
"""
A Dealer could not perform a unregister, since the given registration is not active.
"""
NO_SUCH_SUBSCRIPTION = u"wamp.error.no_such_subscription"
"""
A Broker could not perform a unsubscribe, since the given subscription is not active.
"""
NO_SUCH_SESSION = u"wamp.error.no_such_session"
"""
A router could not perform an operation, since a session ID specified was non-existant.
"""
INVALID_ARGUMENT = u"wamp.error.invalid_argument"
"""
A call failed, since the given argument types or values are not acceptable to the
called procedure - in which case the *Callee* may throw this error. Or a Router
performing *payload validation* checked the payload (``args`` / ``kwargs``) of a call,
call result, call error or publish, and the payload did not conform.
"""
# FIXME: this currently isn't used neither in Autobahn nor Crossbar. Check!
SYSTEM_SHUTDOWN = u"wamp.error.system_shutdown"
"""
The *Peer* is shutting down completely - used as a ``GOODBYE`` (or ``ABORT``) reason.
"""
# FIXME: this currently isn't used neither in Autobahn nor Crossbar. Check!
CLOSE_REALM = u"wamp.error.close_realm"
"""
The *Peer* want to leave the realm - used as a ``GOODBYE`` reason.
"""
# FIXME: this currently isn't used neither in Autobahn nor Crossbar. Check!
GOODBYE_AND_OUT = u"wamp.error.goodbye_and_out"
"""
A *Peer* acknowledges ending of a session - used as a ``GOOBYE`` reply reason.
"""
NOT_AUTHORIZED = u"wamp.error.not_authorized"
"""
A call, register, publish or subscribe failed, since the session is not authorized
to perform the operation.
"""
AUTHORIZATION_FAILED = u"wamp.error.authorization_failed"
"""
A Dealer or Broker could not determine if the *Peer* is authorized to perform
a join, call, register, publish or subscribe, since the authorization operation
*itself* failed. E.g. a custom authorizer did run into an error.
"""
AUTHENTICATION_FAILED = u"wamp.error.authentication_failed"
"""
Something failed with the authentication itself, that is, authentication could
not run to end.
"""
NO_AUTH_METHOD = u"wamp.error.no_auth_method"
"""
No authentication method the peer offered is available or active.
"""
NO_SUCH_REALM = u"wamp.error.no_such_realm"
"""
Peer wanted to join a non-existing realm (and the *Router* did not allow to auto-create
the realm).
"""
NO_SUCH_ROLE = u"wamp.error.no_such_role"
"""
A *Peer* was to be authenticated under a Role that does not (or no longer) exists on the Router.
For example, the *Peer* was successfully authenticated, but the Role configured does not
exists - hence there is some misconfiguration in the Router.
"""
NO_SUCH_PRINCIPAL = u"wamp.error.no_such_principal"
"""
A *Peer* was authenticated for an authid that does not or longer exists.
"""
# FIXME: this currently isn't used neither in Autobahn nor Crossbar. Check!
CANCELED = u"wamp.error.canceled"
"""
A Dealer or Callee canceled a call previously issued (WAMP AP).
"""
# FIXME: this currently isn't used neither in Autobahn nor Crossbar. Check!
NO_ELIGIBLE_CALLEE = u"wamp.error.no_eligible_callee"
"""
A *Dealer* could not perform a call, since a procedure with the given URI is registered,
but *Callee Black- and Whitelisting* and/or *Caller Exclusion* lead to the
exclusion of (any) *Callee* providing the procedure (WAMP AP).
"""
ENC_NO_PAYLOAD_CODEC = u"wamp.error.no_payload_codec"
"""
WAMP message in payload transparency mode received, but no codec set
or codec did not decode the payload.
"""
ENC_TRUSTED_URI_MISMATCH = u"wamp.error.encryption.trusted_uri_mismatch"
"""
WAMP-cryptobox application payload end-to-end encryption error.
"""
ENC_DECRYPT_ERROR = u"wamp.error.encryption.decrypt_error"
"""
WAMP-cryptobox application payload end-to-end encryption error.
"""
def __init__(self, error, *args, **kwargs):
"""
:param error: The URI of the error that occurred, e.g. ``wamp.error.not_authorized``.
:type error: str
"""
Exception.__init__(self, *args)
self.kwargs = kwargs
self.error = error
self.enc_algo = kwargs.pop('enc_algo', None)
@public
def error_message(self):
"""
Get the error message of this exception.
:returns: The error message.
:rtype: str
"""
return u'{0}: {1}'.format(
self.error,
u' '.join([six.text_type(a) for a in self.args]),
)
def __unicode__(self):
if self.kwargs and 'traceback' in self.kwargs:
tb = u':\n' + u'\n'.join(self.kwargs.pop('traceback')) + u'\n'
self.kwargs['traceback'] = u'...'
else:
tb = u''
return u"ApplicationError(error=<{0}>, args={1}, kwargs={2}, enc_algo={3}){4}".format(
self.error, list(self.args), self.kwargs, self.enc_algo, tb)
def __str__(self):
if six.PY3:
return self.__unicode__()
else:
return self.__unicode__().encode('utf8')
@error(ApplicationError.NOT_AUTHORIZED)
class NotAuthorized(Exception):
"""
Not authorized to perform the respective action.
"""
@error(ApplicationError.INVALID_URI)
class InvalidUri(Exception):
"""
The URI for a topic, procedure or error is not a valid WAMP URI.
"""
@error(ApplicationError.INVALID_PAYLOAD)
class InvalidPayload(Exception):
"""
The URI for a topic, procedure or error is not a valid WAMP URI.
"""
|