2016-01-06 21:26:29 -07:00
|
|
|
# Copyright 2014-2016 OpenMarket Ltd
|
2019-04-11 10:08:13 -06:00
|
|
|
# Copyright 2018 New Vector Ltd
|
2014-08-12 08:10:52 -06:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2014-08-12 20:14:34 -06:00
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
"""Contains exceptions and error codes."""
|
2020-07-15 11:40:54 -06:00
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
import logging
|
2020-07-14 05:03:58 -06:00
|
|
|
import typing
|
2022-05-20 06:53:25 -06:00
|
|
|
from enum import Enum
|
2020-06-16 06:51:47 -06:00
|
|
|
from http import HTTPStatus
|
2021-10-18 13:01:10 -06:00
|
|
|
from typing import Any, Dict, List, Optional, Union
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2020-01-15 08:58:55 -07:00
|
|
|
from twisted.web import http
|
|
|
|
|
2020-08-19 05:26:03 -06:00
|
|
|
from synapse.util import json_decoder
|
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
if typing.TYPE_CHECKING:
|
2022-07-27 06:44:40 -06:00
|
|
|
from synapse.config.homeserver import HomeServerConfig
|
2020-07-14 05:03:58 -06:00
|
|
|
from synapse.types import JsonDict
|
|
|
|
|
2014-11-20 10:10:37 -07:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2022-05-20 06:53:25 -06:00
|
|
|
class Codes(str, Enum):
|
|
|
|
"""
|
|
|
|
All known error codes, as an enum of strings.
|
|
|
|
"""
|
|
|
|
|
2015-01-22 10:38:53 -07:00
|
|
|
UNRECOGNIZED = "M_UNRECOGNIZED"
|
2014-10-13 09:39:15 -06:00
|
|
|
UNAUTHORIZED = "M_UNAUTHORIZED"
|
2014-08-12 08:10:52 -06:00
|
|
|
FORBIDDEN = "M_FORBIDDEN"
|
|
|
|
BAD_JSON = "M_BAD_JSON"
|
|
|
|
NOT_JSON = "M_NOT_JSON"
|
|
|
|
USER_IN_USE = "M_USER_IN_USE"
|
|
|
|
ROOM_IN_USE = "M_ROOM_IN_USE"
|
|
|
|
BAD_PAGINATION = "M_BAD_PAGINATION"
|
2016-01-15 09:27:26 -07:00
|
|
|
BAD_STATE = "M_BAD_STATE"
|
2014-08-12 08:10:52 -06:00
|
|
|
UNKNOWN = "M_UNKNOWN"
|
|
|
|
NOT_FOUND = "M_NOT_FOUND"
|
2015-04-23 06:23:44 -06:00
|
|
|
MISSING_TOKEN = "M_MISSING_TOKEN"
|
2014-08-14 06:47:39 -06:00
|
|
|
UNKNOWN_TOKEN = "M_UNKNOWN_TOKEN"
|
2015-11-04 10:29:07 -07:00
|
|
|
GUEST_ACCESS_FORBIDDEN = "M_GUEST_ACCESS_FORBIDDEN"
|
2014-09-02 10:57:04 -06:00
|
|
|
LIMIT_EXCEEDED = "M_LIMIT_EXCEEDED"
|
2014-09-05 20:18:23 -06:00
|
|
|
CAPTCHA_NEEDED = "M_CAPTCHA_NEEDED"
|
|
|
|
CAPTCHA_INVALID = "M_CAPTCHA_INVALID"
|
2015-04-24 02:27:42 -06:00
|
|
|
MISSING_PARAM = "M_MISSING_PARAM"
|
2016-11-21 06:13:55 -07:00
|
|
|
INVALID_PARAM = "M_INVALID_PARAM"
|
2015-04-24 02:27:42 -06:00
|
|
|
TOO_LARGE = "M_TOO_LARGE"
|
2015-02-06 03:57:14 -07:00
|
|
|
EXCLUSIVE = "M_EXCLUSIVE"
|
2015-04-23 11:20:17 -06:00
|
|
|
THREEPID_AUTH_FAILED = "M_THREEPID_AUTH_FAILED"
|
2016-06-30 10:51:28 -06:00
|
|
|
THREEPID_IN_USE = "M_THREEPID_IN_USE"
|
2016-07-08 10:42:48 -06:00
|
|
|
THREEPID_NOT_FOUND = "M_THREEPID_NOT_FOUND"
|
2018-01-18 17:19:58 -07:00
|
|
|
THREEPID_DENIED = "M_THREEPID_DENIED"
|
2016-01-15 03:06:34 -07:00
|
|
|
INVALID_USERNAME = "M_INVALID_USERNAME"
|
2016-06-30 10:51:28 -06:00
|
|
|
SERVER_NOT_TRUSTED = "M_SERVER_NOT_TRUSTED"
|
2018-05-22 01:56:52 -06:00
|
|
|
CONSENT_NOT_GIVEN = "M_CONSENT_NOT_GIVEN"
|
2018-05-22 10:27:03 -06:00
|
|
|
CANNOT_LEAVE_SERVER_NOTICE_ROOM = "M_CANNOT_LEAVE_SERVER_NOTICE_ROOM"
|
2018-08-18 07:39:45 -06:00
|
|
|
RESOURCE_LIMIT_EXCEEDED = "M_RESOURCE_LIMIT_EXCEEDED"
|
2018-07-25 15:10:39 -06:00
|
|
|
UNSUPPORTED_ROOM_VERSION = "M_UNSUPPORTED_ROOM_VERSION"
|
2018-07-25 15:25:41 -06:00
|
|
|
INCOMPATIBLE_ROOM_VERSION = "M_INCOMPATIBLE_ROOM_VERSION"
|
2017-12-05 18:02:57 -07:00
|
|
|
WRONG_ROOM_KEYS_VERSION = "M_WRONG_ROOM_KEYS_VERSION"
|
2019-04-08 10:10:55 -06:00
|
|
|
EXPIRED_ACCOUNT = "ORG_MATRIX_EXPIRED_ACCOUNT"
|
2020-03-26 10:51:13 -06:00
|
|
|
PASSWORD_TOO_SHORT = "M_PASSWORD_TOO_SHORT"
|
|
|
|
PASSWORD_NO_DIGIT = "M_PASSWORD_NO_DIGIT"
|
|
|
|
PASSWORD_NO_UPPERCASE = "M_PASSWORD_NO_UPPERCASE"
|
|
|
|
PASSWORD_NO_LOWERCASE = "M_PASSWORD_NO_LOWERCASE"
|
|
|
|
PASSWORD_NO_SYMBOL = "M_PASSWORD_NO_SYMBOL"
|
|
|
|
PASSWORD_IN_DICTIONARY = "M_PASSWORD_IN_DICTIONARY"
|
|
|
|
WEAK_PASSWORD = "M_WEAK_PASSWORD"
|
2019-07-25 09:08:24 -06:00
|
|
|
INVALID_SIGNATURE = "M_INVALID_SIGNATURE"
|
2019-07-31 08:19:06 -06:00
|
|
|
USER_DEACTIVATED = "M_USER_DEACTIVATED"
|
2022-05-27 07:13:29 -06:00
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
# Part of MSC3848
|
|
|
|
# https://github.com/matrix-org/matrix-spec-proposals/pull/3848
|
|
|
|
ALREADY_JOINED = "ORG.MATRIX.MSC3848.ALREADY_JOINED"
|
|
|
|
NOT_JOINED = "ORG.MATRIX.MSC3848.NOT_JOINED"
|
|
|
|
INSUFFICIENT_POWER = "ORG.MATRIX.MSC3848.INSUFFICIENT_POWER"
|
|
|
|
|
2022-05-27 07:13:29 -06:00
|
|
|
# The account has been suspended on the server.
|
|
|
|
# By opposition to `USER_DEACTIVATED`, this is a reversible measure
|
|
|
|
# that can possibly be appealed and reverted.
|
|
|
|
# Part of MSC3823.
|
2022-05-31 01:42:18 -06:00
|
|
|
USER_ACCOUNT_SUSPENDED = "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
|
2022-05-27 07:13:29 -06:00
|
|
|
|
2020-03-03 05:12:45 -07:00
|
|
|
BAD_ALIAS = "M_BAD_ALIAS"
|
2021-07-26 10:17:00 -06:00
|
|
|
# For restricted join rules.
|
|
|
|
UNABLE_AUTHORISE_JOIN = "M_UNABLE_TO_AUTHORISE_JOIN"
|
|
|
|
UNABLE_TO_GRANT_JOIN = "M_UNABLE_TO_GRANT_JOIN"
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2022-04-20 05:57:39 -06:00
|
|
|
UNREDACTED_CONTENT_DELETED = "FI.MAU.MSC2815_UNREDACTED_CONTENT_DELETED"
|
|
|
|
|
2022-09-23 04:47:16 -06:00
|
|
|
# Returned for federation requests where we can't process a request as we
|
|
|
|
# can't ensure the sending server is in a room which is partial-stated on
|
|
|
|
# our side.
|
|
|
|
# Part of MSC3895.
|
|
|
|
UNABLE_DUE_TO_PARTIAL_STATE = "ORG.MATRIX.MSC3895_UNABLE_DUE_TO_PARTIAL_STATE"
|
|
|
|
|
2022-09-29 07:23:24 -06:00
|
|
|
USER_AWAITING_APPROVAL = "ORG.MATRIX.MSC3866_USER_AWAITING_APPROVAL"
|
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2015-02-04 09:28:12 -07:00
|
|
|
class CodeMessageException(RuntimeError):
|
2017-03-13 07:50:16 -06:00
|
|
|
"""An exception with integer code and message string attributes.
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2017-03-13 07:50:16 -06:00
|
|
|
Attributes:
|
2020-07-14 05:03:58 -06:00
|
|
|
code: HTTP error code
|
|
|
|
msg: string describing the error
|
2017-03-13 07:50:16 -06:00
|
|
|
"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, code: Union[int, HTTPStatus], msg: str):
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__("%d: %s" % (code, msg))
|
2020-04-03 07:26:07 -06:00
|
|
|
|
|
|
|
# Some calls to this method pass instances of http.HTTPStatus for `code`.
|
|
|
|
# While HTTPStatus is a subclass of int, it has magic __str__ methods
|
|
|
|
# which emit `HTTPStatus.FORBIDDEN` when converted to a str, instead of `403`.
|
|
|
|
# This causes inconsistency in our log lines.
|
|
|
|
#
|
|
|
|
# To eliminate this behaviour, we convert them to their integer equivalents here.
|
|
|
|
self.code = int(code)
|
2017-03-14 06:36:50 -06:00
|
|
|
self.msg = msg
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2017-04-25 12:30:55 -06:00
|
|
|
|
2020-01-15 08:58:55 -07:00
|
|
|
class RedirectException(CodeMessageException):
|
|
|
|
"""A pseudo-error indicating that we want to redirect the client to a different
|
|
|
|
location
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
cookies: a list of set-cookies values to add to the response. For example:
|
|
|
|
b"sessionId=a3fWa; Expires=Wed, 21 Oct 2015 07:28:00 GMT"
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, location: bytes, http_code: int = http.FOUND):
|
|
|
|
"""
|
|
|
|
|
|
|
|
Args:
|
|
|
|
location: the URI to redirect to
|
|
|
|
http_code: the HTTP response code
|
|
|
|
"""
|
|
|
|
msg = "Redirect to %s" % (location.decode("utf-8"),)
|
|
|
|
super().__init__(code=http_code, msg=msg)
|
|
|
|
self.location = location
|
|
|
|
|
2021-07-15 04:02:43 -06:00
|
|
|
self.cookies: List[bytes] = []
|
2020-01-15 08:58:55 -07:00
|
|
|
|
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
class SynapseError(CodeMessageException):
|
2017-03-14 06:36:50 -06:00
|
|
|
"""A base exception type for matrix errors which have an errcode and error
|
2022-10-19 14:39:43 -06:00
|
|
|
message (as well as an HTTP status code). These often bubble all the way up to the
|
|
|
|
client API response so the error code and status often reach the client directly as
|
|
|
|
defined here. If the error doesn't make sense to present to a client, then it
|
|
|
|
probably shouldn't be a `SynapseError`. For example, if we contact another
|
|
|
|
homeserver over federation, we shouldn't automatically ferry response errors back to
|
|
|
|
the client on our end (a 500 from a remote server does not make sense to a client
|
|
|
|
when our server did not experience a 500).
|
2017-03-14 06:36:50 -06:00
|
|
|
|
|
|
|
Attributes:
|
2020-07-14 05:03:58 -06:00
|
|
|
errcode: Matrix error code e.g 'M_FORBIDDEN'
|
2017-03-14 06:36:50 -06:00
|
|
|
"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2022-05-30 10:24:56 -06:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
code: int,
|
|
|
|
msg: str,
|
|
|
|
errcode: str = Codes.UNKNOWN,
|
|
|
|
additional_fields: Optional[Dict] = None,
|
|
|
|
):
|
2014-08-12 08:10:52 -06:00
|
|
|
"""Constructs a synapse error.
|
|
|
|
|
|
|
|
Args:
|
2020-07-14 05:03:58 -06:00
|
|
|
code: The integer error code (an HTTP response code)
|
|
|
|
msg: The human-readable error message.
|
|
|
|
errcode: The matrix error code e.g 'M_FORBIDDEN'
|
2014-08-12 08:10:52 -06:00
|
|
|
"""
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(code, msg)
|
2014-08-12 08:10:52 -06:00
|
|
|
self.errcode = errcode
|
2022-05-30 10:24:56 -06:00
|
|
|
if additional_fields is None:
|
|
|
|
self._additional_fields: Dict = {}
|
|
|
|
else:
|
|
|
|
self._additional_fields = dict(additional_fields)
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
2022-05-30 10:24:56 -06:00
|
|
|
return cs_error(self.msg, self.errcode, **self._additional_fields)
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2017-03-14 07:36:06 -06:00
|
|
|
|
2021-08-20 08:47:03 -06:00
|
|
|
class InvalidAPICallError(SynapseError):
|
|
|
|
"""You called an existing API endpoint, but fed that endpoint
|
|
|
|
invalid or incomplete data."""
|
|
|
|
|
|
|
|
def __init__(self, msg: str):
|
|
|
|
super().__init__(HTTPStatus.BAD_REQUEST, msg, Codes.BAD_JSON)
|
|
|
|
|
|
|
|
|
2018-08-01 07:58:16 -06:00
|
|
|
class ProxiedRequestError(SynapseError):
|
|
|
|
"""An error from a general matrix endpoint, eg. from a proxied Matrix API call.
|
2017-03-13 07:50:16 -06:00
|
|
|
|
2018-08-01 07:58:16 -06:00
|
|
|
Attributes:
|
2020-07-14 05:03:58 -06:00
|
|
|
errcode: Matrix error code e.g 'M_FORBIDDEN'
|
2018-08-01 07:58:16 -06:00
|
|
|
"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
code: int,
|
|
|
|
msg: str,
|
|
|
|
errcode: str = Codes.UNKNOWN,
|
|
|
|
additional_fields: Optional[Dict] = None,
|
|
|
|
):
|
2022-05-30 10:24:56 -06:00
|
|
|
super().__init__(code, msg, errcode, additional_fields)
|
2017-03-13 07:50:16 -06:00
|
|
|
|
2014-10-30 05:10:17 -06:00
|
|
|
|
2018-05-22 01:56:52 -06:00
|
|
|
class ConsentNotGivenError(SynapseError):
|
|
|
|
"""The error returned to the client when the user has not consented to the
|
|
|
|
privacy policy.
|
|
|
|
"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, msg: str, consent_uri: str):
|
2018-05-22 01:56:52 -06:00
|
|
|
"""Constructs a ConsentNotGivenError
|
|
|
|
|
|
|
|
Args:
|
2020-07-14 05:03:58 -06:00
|
|
|
msg: The human-readable error message
|
|
|
|
consent_url: The URL where the user can give their consent
|
2018-05-22 01:56:52 -06:00
|
|
|
"""
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(
|
2020-06-16 06:51:47 -06:00
|
|
|
code=HTTPStatus.FORBIDDEN, msg=msg, errcode=Codes.CONSENT_NOT_GIVEN
|
2018-05-22 01:56:52 -06:00
|
|
|
)
|
|
|
|
self._consent_uri = consent_uri
|
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
2018-05-22 01:56:52 -06:00
|
|
|
return cs_error(self.msg, self.errcode, consent_uri=self._consent_uri)
|
|
|
|
|
|
|
|
|
2019-07-15 04:45:29 -06:00
|
|
|
class UserDeactivatedError(SynapseError):
|
|
|
|
"""The error returned to the client when the user attempted to access an
|
|
|
|
authenticated endpoint, but the account has been deactivated.
|
|
|
|
"""
|
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, msg: str):
|
2019-07-15 04:45:29 -06:00
|
|
|
"""Constructs a UserDeactivatedError
|
|
|
|
|
|
|
|
Args:
|
2020-07-14 05:03:58 -06:00
|
|
|
msg: The human-readable error message
|
2019-07-15 04:45:29 -06:00
|
|
|
"""
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(
|
2020-06-16 06:51:47 -06:00
|
|
|
code=HTTPStatus.FORBIDDEN, msg=msg, errcode=Codes.USER_DEACTIVATED
|
2019-07-15 04:45:29 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-01-22 11:11:18 -07:00
|
|
|
class FederationDeniedError(SynapseError):
|
|
|
|
"""An error raised when the server tries to federate with a server which
|
|
|
|
is not on its federation whitelist.
|
|
|
|
|
|
|
|
Attributes:
|
2020-07-14 05:03:58 -06:00
|
|
|
destination: The destination which has been denied
|
2018-01-22 11:11:18 -07:00
|
|
|
"""
|
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, destination: Optional[str]):
|
2018-01-22 11:11:18 -07:00
|
|
|
"""Raised by federation client or server to indicate that we are
|
|
|
|
are deliberately not attempting to contact a given server because it is
|
|
|
|
not on our federation whitelist.
|
|
|
|
|
|
|
|
Args:
|
2020-07-14 05:03:58 -06:00
|
|
|
destination: the domain in question
|
2018-01-22 11:11:18 -07:00
|
|
|
"""
|
|
|
|
|
|
|
|
self.destination = destination
|
|
|
|
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(
|
2018-01-22 11:11:18 -07:00
|
|
|
code=403,
|
|
|
|
msg="Federation denied with %s." % (self.destination,),
|
|
|
|
errcode=Codes.FORBIDDEN,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2017-12-04 08:47:27 -07:00
|
|
|
class InteractiveAuthIncompleteError(Exception):
|
|
|
|
"""An error raised when UI auth is not yet complete
|
|
|
|
|
|
|
|
(This indicates we should return a 401 with 'result' as the body)
|
|
|
|
|
|
|
|
Attributes:
|
2020-08-06 06:09:55 -06:00
|
|
|
session_id: The ID of the ongoing interactive auth session.
|
2020-07-14 05:03:58 -06:00
|
|
|
result: the server response to the request, which should be
|
2017-12-04 08:47:27 -07:00
|
|
|
passed back to the client
|
|
|
|
"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2020-08-06 06:09:55 -06:00
|
|
|
def __init__(self, session_id: str, result: "JsonDict"):
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__("Interactive auth not yet complete")
|
2020-08-06 06:09:55 -06:00
|
|
|
self.session_id = session_id
|
2017-12-04 08:47:27 -07:00
|
|
|
self.result = result
|
|
|
|
|
|
|
|
|
2015-01-22 10:38:53 -07:00
|
|
|
class UnrecognizedRequestError(SynapseError):
|
|
|
|
"""An error indicating we don't understand the request you're trying to make"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2021-10-18 13:01:10 -06:00
|
|
|
def __init__(
|
2022-05-23 11:27:39 -06:00
|
|
|
self, msg: str = "Unrecognized request", errcode: str = Codes.UNRECOGNIZED
|
2021-10-18 13:01:10 -06:00
|
|
|
):
|
|
|
|
super().__init__(400, msg, errcode)
|
2015-01-22 10:38:53 -07:00
|
|
|
|
2015-01-22 12:32:17 -07:00
|
|
|
|
|
|
|
class NotFoundError(SynapseError):
|
|
|
|
"""An error indicating we can't find the thing you asked for"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, msg: str = "Not found", errcode: str = Codes.NOT_FOUND):
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(404, msg, errcode=errcode)
|
2015-01-22 12:32:17 -07:00
|
|
|
|
2015-01-29 09:10:35 -07:00
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
class AuthError(SynapseError):
|
2019-07-11 04:06:23 -06:00
|
|
|
"""An error raised when there was a problem authorising an event, and at various
|
|
|
|
other poorly-defined times.
|
|
|
|
"""
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2022-07-11 10:52:10 -06:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
code: int,
|
|
|
|
msg: str,
|
|
|
|
errcode: str = Codes.FORBIDDEN,
|
|
|
|
additional_fields: Optional[dict] = None,
|
|
|
|
):
|
|
|
|
super().__init__(code, msg, errcode, additional_fields)
|
2014-08-12 08:10:52 -06:00
|
|
|
|
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
class UnstableSpecAuthError(AuthError):
|
|
|
|
"""An error raised when a new error code is being proposed to replace a previous one.
|
|
|
|
This error will return a "org.matrix.unstable.errcode" property with the new error code,
|
|
|
|
with the previous error code still being defined in the "errcode" property.
|
|
|
|
|
|
|
|
This error will include `org.matrix.msc3848.unstable.errcode` in the C-S error body.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
code: int,
|
|
|
|
msg: str,
|
|
|
|
errcode: str,
|
|
|
|
previous_errcode: str = Codes.FORBIDDEN,
|
|
|
|
additional_fields: Optional[dict] = None,
|
|
|
|
):
|
|
|
|
self.previous_errcode = previous_errcode
|
|
|
|
super().__init__(code, msg, errcode, additional_fields)
|
|
|
|
|
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
|
|
|
fields = {}
|
|
|
|
if config is not None and config.experimental.msc3848_enabled:
|
|
|
|
fields["org.matrix.msc3848.unstable.errcode"] = self.errcode
|
|
|
|
return cs_error(
|
|
|
|
self.msg,
|
|
|
|
self.previous_errcode,
|
|
|
|
**fields,
|
|
|
|
**self._additional_fields,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-07-11 04:06:23 -06:00
|
|
|
class InvalidClientCredentialsError(SynapseError):
|
|
|
|
"""An error raised when there was a problem with the authorisation credentials
|
|
|
|
in a client request.
|
|
|
|
|
|
|
|
https://matrix.org/docs/spec/client_server/r0.5.0#using-access-tokens:
|
|
|
|
|
|
|
|
When credentials are required but missing or invalid, the HTTP call will
|
|
|
|
return with a status of 401 and the error code, M_MISSING_TOKEN or
|
|
|
|
M_UNKNOWN_TOKEN respectively.
|
|
|
|
"""
|
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, msg: str, errcode: str):
|
2019-07-11 04:06:23 -06:00
|
|
|
super().__init__(code=401, msg=msg, errcode=errcode)
|
|
|
|
|
|
|
|
|
|
|
|
class MissingClientTokenError(InvalidClientCredentialsError):
|
|
|
|
"""Raised when we couldn't find the access token in a request"""
|
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, msg: str = "Missing access token"):
|
2019-07-11 04:06:23 -06:00
|
|
|
super().__init__(msg=msg, errcode="M_MISSING_TOKEN")
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidClientTokenError(InvalidClientCredentialsError):
|
|
|
|
"""Raised when we didn't understand the access token in a request"""
|
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(
|
|
|
|
self, msg: str = "Unrecognised access token", soft_logout: bool = False
|
|
|
|
):
|
2019-07-11 04:06:23 -06:00
|
|
|
super().__init__(msg=msg, errcode="M_UNKNOWN_TOKEN")
|
2019-07-12 10:26:02 -06:00
|
|
|
self._soft_logout = soft_logout
|
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
|
|
|
d = super().error_dict(config)
|
2019-07-12 10:26:02 -06:00
|
|
|
d["soft_logout"] = self._soft_logout
|
|
|
|
return d
|
2019-07-11 04:06:23 -06:00
|
|
|
|
|
|
|
|
2018-08-16 11:02:02 -06:00
|
|
|
class ResourceLimitError(SynapseError):
|
|
|
|
"""
|
|
|
|
Any error raised when there is a problem with resource usage.
|
|
|
|
For instance, the monthly active user limit for the server has been exceeded
|
|
|
|
"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2018-08-16 11:02:02 -06:00
|
|
|
def __init__(
|
|
|
|
self,
|
2020-07-14 05:03:58 -06:00
|
|
|
code: int,
|
|
|
|
msg: str,
|
|
|
|
errcode: str = Codes.RESOURCE_LIMIT_EXCEEDED,
|
|
|
|
admin_contact: Optional[str] = None,
|
|
|
|
limit_type: Optional[str] = None,
|
2018-08-16 11:02:02 -06:00
|
|
|
):
|
2018-08-24 09:51:27 -06:00
|
|
|
self.admin_contact = admin_contact
|
2018-08-16 11:02:02 -06:00
|
|
|
self.limit_type = limit_type
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(code, msg, errcode=errcode)
|
2018-08-13 11:00:23 -06:00
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
2018-08-13 11:00:23 -06:00
|
|
|
return cs_error(
|
|
|
|
self.msg,
|
|
|
|
self.errcode,
|
2018-08-24 09:51:27 -06:00
|
|
|
admin_contact=self.admin_contact,
|
2018-08-16 11:02:02 -06:00
|
|
|
limit_type=self.limit_type,
|
2018-08-13 11:00:23 -06:00
|
|
|
)
|
2014-08-12 08:10:52 -06:00
|
|
|
|
|
|
|
|
2015-10-22 04:44:31 -06:00
|
|
|
class EventSizeError(SynapseError):
|
|
|
|
"""An error raised when an event is too big."""
|
|
|
|
|
2021-10-18 13:01:10 -06:00
|
|
|
def __init__(self, msg: str):
|
|
|
|
super().__init__(413, msg, Codes.TOO_LARGE)
|
2014-08-12 08:10:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
class LoginError(SynapseError):
|
|
|
|
"""An error raised when there was a problem logging in."""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
|
|
|
|
class StoreError(SynapseError):
|
|
|
|
"""An error raised when there was a problem storing some data."""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2014-09-05 20:18:23 -06:00
|
|
|
class InvalidCaptchaError(SynapseError):
|
|
|
|
def __init__(
|
|
|
|
self,
|
2020-07-14 05:03:58 -06:00
|
|
|
code: int = 400,
|
|
|
|
msg: str = "Invalid captcha.",
|
|
|
|
error_url: Optional[str] = None,
|
|
|
|
errcode: str = Codes.CAPTCHA_INVALID,
|
2014-09-05 20:18:23 -06:00
|
|
|
):
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(code, msg, errcode)
|
2014-09-05 20:18:23 -06:00
|
|
|
self.error_url = error_url
|
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
2014-09-05 20:18:23 -06:00
|
|
|
return cs_error(self.msg, self.errcode, error_url=self.error_url)
|
|
|
|
|
2014-10-30 05:10:17 -06:00
|
|
|
|
2014-09-03 01:58:48 -06:00
|
|
|
class LimitExceededError(SynapseError):
|
|
|
|
"""A client has sent too many requests and is being throttled."""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2014-09-03 01:58:48 -06:00
|
|
|
def __init__(
|
|
|
|
self,
|
2020-07-14 05:03:58 -06:00
|
|
|
code: int = 429,
|
|
|
|
msg: str = "Too Many Requests",
|
|
|
|
retry_after_ms: Optional[int] = None,
|
|
|
|
errcode: str = Codes.LIMIT_EXCEEDED,
|
2014-09-03 01:58:48 -06:00
|
|
|
):
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(code, msg, errcode)
|
2014-09-03 01:58:48 -06:00
|
|
|
self.retry_after_ms = retry_after_ms
|
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
2014-09-03 01:58:48 -06:00
|
|
|
return cs_error(self.msg, self.errcode, retry_after_ms=self.retry_after_ms)
|
|
|
|
|
|
|
|
|
2017-12-05 18:02:57 -07:00
|
|
|
class RoomKeysVersionError(SynapseError):
|
|
|
|
"""A client has tried to upload to a non-current version of the room_keys store"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, current_version: str):
|
2017-12-17 18:52:46 -07:00
|
|
|
"""
|
|
|
|
Args:
|
2020-07-14 05:03:58 -06:00
|
|
|
current_version: the current version of the store they should have used
|
2017-12-17 18:52:46 -07:00
|
|
|
"""
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(403, "Wrong room_keys version", Codes.WRONG_ROOM_KEYS_VERSION)
|
2017-12-05 18:02:57 -07:00
|
|
|
self.current_version = current_version
|
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
2022-02-14 12:28:00 -07:00
|
|
|
return cs_error(self.msg, self.errcode, current_version=self.current_version)
|
|
|
|
|
2018-09-06 09:23:16 -06:00
|
|
|
|
2019-05-21 06:47:25 -06:00
|
|
|
class UnsupportedRoomVersionError(SynapseError):
|
|
|
|
"""The client's request to create a room used a room version that the server does
|
|
|
|
not support."""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, msg: str = "Homeserver does not support this room version"):
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(
|
2020-01-31 03:28:15 -07:00
|
|
|
code=400,
|
|
|
|
msg=msg,
|
|
|
|
errcode=Codes.UNSUPPORTED_ROOM_VERSION,
|
2019-05-21 06:47:25 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-06-06 10:34:07 -06:00
|
|
|
class ThreepidValidationError(SynapseError):
|
|
|
|
"""An error raised when there was a problem authorising an event."""
|
|
|
|
|
2021-10-18 13:01:10 -06:00
|
|
|
def __init__(self, msg: str, errcode: str = Codes.FORBIDDEN):
|
|
|
|
super().__init__(400, msg, errcode)
|
2019-06-06 10:34:07 -06:00
|
|
|
|
|
|
|
|
2018-07-25 15:25:41 -06:00
|
|
|
class IncompatibleRoomVersionError(SynapseError):
|
2019-05-21 06:47:25 -06:00
|
|
|
"""A server is trying to join a room whose version it does not support.
|
2018-07-25 15:25:41 -06:00
|
|
|
|
2019-05-21 06:47:25 -06:00
|
|
|
Unlike UnsupportedRoomVersionError, it is specific to the case of the make_join
|
|
|
|
failing.
|
|
|
|
"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, room_version: str):
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(
|
2018-07-25 15:25:41 -06:00
|
|
|
code=400,
|
|
|
|
msg="Your homeserver does not support the features required to "
|
2021-06-09 12:39:51 -06:00
|
|
|
"interact with this room",
|
2018-07-25 15:25:41 -06:00
|
|
|
errcode=Codes.INCOMPATIBLE_ROOM_VERSION,
|
|
|
|
)
|
|
|
|
|
|
|
|
self._room_version = room_version
|
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
2018-10-09 11:04:21 -06:00
|
|
|
return cs_error(self.msg, self.errcode, room_version=self._room_version)
|
2017-12-05 18:02:57 -07:00
|
|
|
|
|
|
|
|
2020-03-26 10:51:13 -06:00
|
|
|
class PasswordRefusedError(SynapseError):
|
|
|
|
"""A password has been refused, either during password reset/change or registration."""
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
2020-07-14 05:03:58 -06:00
|
|
|
msg: str = "This password doesn't comply with the server's policy",
|
|
|
|
errcode: str = Codes.WEAK_PASSWORD,
|
2020-03-26 10:51:13 -06:00
|
|
|
):
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(
|
2020-03-26 10:51:13 -06:00
|
|
|
code=400,
|
|
|
|
msg=msg,
|
|
|
|
errcode=errcode,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-01-08 04:04:28 -07:00
|
|
|
class RequestSendFailed(RuntimeError):
|
|
|
|
"""Sending a HTTP request over federation failed due to not being able to
|
|
|
|
talk to the remote server for some reason.
|
|
|
|
|
|
|
|
This exception is used to differentiate "expected" errors that arise due to
|
|
|
|
networking (e.g. DNS failures, connection timeouts etc), versus unexpected
|
|
|
|
errors (like programming errors).
|
|
|
|
"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2021-10-18 13:01:10 -06:00
|
|
|
def __init__(self, inner_exception: BaseException, can_retry: bool):
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(
|
2019-01-08 04:04:28 -07:00
|
|
|
"Failed to send request: %s: %s"
|
|
|
|
% (type(inner_exception).__name__, inner_exception)
|
|
|
|
)
|
|
|
|
self.inner_exception = inner_exception
|
|
|
|
self.can_retry = can_retry
|
|
|
|
|
|
|
|
|
2022-04-20 05:57:39 -06:00
|
|
|
class UnredactedContentDeletedError(SynapseError):
|
|
|
|
def __init__(self, content_keep_ms: Optional[int] = None):
|
|
|
|
super().__init__(
|
|
|
|
404,
|
|
|
|
"The content for that event has already been erased from the database",
|
|
|
|
errcode=Codes.UNREDACTED_CONTENT_DELETED,
|
|
|
|
)
|
|
|
|
self.content_keep_ms = content_keep_ms
|
|
|
|
|
2022-07-27 06:44:40 -06:00
|
|
|
def error_dict(self, config: Optional["HomeServerConfig"]) -> "JsonDict":
|
2022-04-20 05:57:39 -06:00
|
|
|
extra = {}
|
|
|
|
if self.content_keep_ms is not None:
|
|
|
|
extra = {"fi.mau.msc2815.content_keep_ms": self.content_keep_ms}
|
|
|
|
return cs_error(self.msg, self.errcode, **extra)
|
|
|
|
|
|
|
|
|
2022-09-29 07:23:24 -06:00
|
|
|
class NotApprovedError(SynapseError):
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
msg: str,
|
|
|
|
approval_notice_medium: str,
|
|
|
|
):
|
|
|
|
super().__init__(
|
|
|
|
code=403,
|
|
|
|
msg=msg,
|
|
|
|
errcode=Codes.USER_AWAITING_APPROVAL,
|
|
|
|
additional_fields={"approval_notice_medium": approval_notice_medium},
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-10-18 13:01:10 -06:00
|
|
|
def cs_error(msg: str, code: str = Codes.UNKNOWN, **kwargs: Any) -> "JsonDict":
|
2014-08-12 08:10:52 -06:00
|
|
|
"""Utility method for constructing an error response for client-server
|
|
|
|
interactions.
|
|
|
|
|
|
|
|
Args:
|
2020-07-14 05:03:58 -06:00
|
|
|
msg: The error message.
|
|
|
|
code: The error code.
|
|
|
|
kwargs: Additional keys to add to the response.
|
2014-08-12 08:10:52 -06:00
|
|
|
Returns:
|
|
|
|
A dict representing the error response JSON.
|
|
|
|
"""
|
|
|
|
err = {"error": msg, "errcode": code}
|
2020-06-15 05:03:36 -06:00
|
|
|
for key, value in kwargs.items():
|
2014-08-12 08:10:52 -06:00
|
|
|
err[key] = value
|
|
|
|
return err
|
2014-11-04 08:10:27 -07:00
|
|
|
|
|
|
|
|
|
|
|
class FederationError(RuntimeError):
|
2022-10-19 14:39:43 -06:00
|
|
|
"""
|
|
|
|
Raised when we process an erroneous PDU.
|
|
|
|
|
|
|
|
There are two kinds of scenarios where this exception can be raised:
|
|
|
|
|
|
|
|
1. We may pull an invalid PDU from a remote homeserver (e.g. during backfill). We
|
|
|
|
raise this exception to signal an error to the rest of the application.
|
|
|
|
2. We may be pushed an invalid PDU as part of a `/send` transaction from a remote
|
|
|
|
homeserver. We raise so that we can respond to the transaction and include the
|
|
|
|
error string in the "PDU Processing Result". The message which will likely be
|
|
|
|
ignored by the remote homeserver and is not machine parse-able since it's just a
|
|
|
|
string.
|
|
|
|
|
|
|
|
TODO: In the future, we should split these usage scenarios into their own error types.
|
2014-11-04 08:10:27 -07:00
|
|
|
|
|
|
|
FATAL: The remote server could not interpret the source event.
|
|
|
|
(e.g., it was missing a required field)
|
|
|
|
ERROR: The remote server interpreted the event, but it failed some other
|
|
|
|
check (e.g. auth)
|
|
|
|
WARN: The remote server accepted the event, but believes some part of it
|
|
|
|
is wrong (e.g., it referred to an invalid event)
|
|
|
|
"""
|
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
level: str,
|
|
|
|
code: int,
|
|
|
|
reason: str,
|
|
|
|
affected: str,
|
|
|
|
source: Optional[str] = None,
|
|
|
|
):
|
2014-11-04 08:10:27 -07:00
|
|
|
if level not in ["FATAL", "ERROR", "WARN"]:
|
|
|
|
raise ValueError("Level is not valid: %s" % (level,))
|
|
|
|
self.level = level
|
|
|
|
self.code = code
|
|
|
|
self.reason = reason
|
|
|
|
self.affected = affected
|
|
|
|
self.source = source
|
|
|
|
|
|
|
|
msg = "%s %s: %s" % (level, code, reason)
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(msg)
|
2014-11-04 08:10:27 -07:00
|
|
|
|
2021-10-18 13:01:10 -06:00
|
|
|
def get_dict(self) -> "JsonDict":
|
2014-11-04 08:10:27 -07:00
|
|
|
return {
|
|
|
|
"level": self.level,
|
|
|
|
"code": self.code,
|
|
|
|
"reason": self.reason,
|
|
|
|
"affected": self.affected,
|
|
|
|
"source": self.source if self.source else self.affected,
|
|
|
|
}
|
2015-02-04 09:28:12 -07:00
|
|
|
|
|
|
|
|
2022-10-14 23:36:49 -06:00
|
|
|
class FederationPullAttemptBackoffError(RuntimeError):
|
|
|
|
"""
|
|
|
|
Raised to indicate that we are are deliberately not attempting to pull the given
|
|
|
|
event over federation because we've already done so recently and are backing off.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
event_id: The event_id which we are refusing to pull
|
|
|
|
message: A custom error message that gives more context
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, event_ids: List[str], message: Optional[str]):
|
|
|
|
self.event_ids = event_ids
|
|
|
|
|
|
|
|
if message:
|
|
|
|
error_message = message
|
|
|
|
else:
|
|
|
|
error_message = f"Not attempting to pull event_ids={self.event_ids} because we already tried to pull them recently (backing off)."
|
|
|
|
|
|
|
|
super().__init__(error_message)
|
|
|
|
|
|
|
|
|
2015-02-04 09:28:12 -07:00
|
|
|
class HttpResponseException(CodeMessageException):
|
2017-03-13 07:50:16 -06:00
|
|
|
"""
|
|
|
|
Represents an HTTP-level failure of an outbound request
|
|
|
|
|
|
|
|
Attributes:
|
2020-07-14 05:03:58 -06:00
|
|
|
response: body of response
|
2017-03-13 07:50:16 -06:00
|
|
|
"""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2020-07-14 05:03:58 -06:00
|
|
|
def __init__(self, code: int, msg: str, response: bytes):
|
2017-03-13 07:50:16 -06:00
|
|
|
"""
|
|
|
|
|
|
|
|
Args:
|
2020-07-14 05:03:58 -06:00
|
|
|
code: HTTP status code
|
|
|
|
msg: reason phrase from HTTP response status line
|
|
|
|
response: body of response
|
2017-03-13 07:50:16 -06:00
|
|
|
"""
|
2020-09-18 07:56:44 -06:00
|
|
|
super().__init__(code, msg)
|
2015-02-04 09:28:12 -07:00
|
|
|
self.response = response
|
2018-08-01 07:58:16 -06:00
|
|
|
|
2021-10-18 13:01:10 -06:00
|
|
|
def to_synapse_error(self) -> SynapseError:
|
2018-08-01 07:58:16 -06:00
|
|
|
"""Make a SynapseError based on an HTTPResponseException
|
|
|
|
|
|
|
|
This is useful when a proxied request has failed, and we need to
|
|
|
|
decide how to map the failure onto a matrix error to send back to the
|
|
|
|
client.
|
|
|
|
|
|
|
|
An attempt is made to parse the body of the http response as a matrix
|
|
|
|
error. If that succeeds, the errcode and error message from the body
|
|
|
|
are used as the errcode and error message in the new synapse error.
|
|
|
|
|
|
|
|
Otherwise, the errcode is set to M_UNKNOWN, and the error message is
|
|
|
|
set to the reason code from the HTTP response.
|
|
|
|
|
|
|
|
Returns:
|
2022-11-16 08:25:24 -07:00
|
|
|
The error converted to a SynapseError.
|
2018-08-01 07:58:16 -06:00
|
|
|
"""
|
|
|
|
# try to parse the body as json, to get better errcode/msg, but
|
|
|
|
# default to M_UNKNOWN with the HTTP status as the error text
|
|
|
|
try:
|
2020-08-19 05:26:03 -06:00
|
|
|
j = json_decoder.decode(self.response.decode("utf-8"))
|
2018-08-01 07:58:16 -06:00
|
|
|
except ValueError:
|
|
|
|
j = {}
|
|
|
|
|
|
|
|
if not isinstance(j, dict):
|
|
|
|
j = {}
|
|
|
|
|
|
|
|
errcode = j.pop("errcode", Codes.UNKNOWN)
|
|
|
|
errmsg = j.pop("error", self.msg)
|
|
|
|
|
|
|
|
return ProxiedRequestError(self.code, errmsg, errcode, j)
|
2020-08-20 13:07:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
class ShadowBanError(Exception):
|
|
|
|
"""
|
|
|
|
Raised when a shadow-banned user attempts to perform an action.
|
|
|
|
|
|
|
|
This should be caught and a proper "fake" success response sent to the user.
|
|
|
|
"""
|
2021-11-01 09:45:56 -06:00
|
|
|
|
|
|
|
|
|
|
|
class ModuleFailedException(Exception):
|
|
|
|
"""
|
|
|
|
Raised when a module API callback fails, for example because it raised an
|
|
|
|
exception.
|
|
|
|
"""
|