diff options
author | Erik Johnston <erik@matrix.org> | 2020-01-22 16:53:28 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2020-01-22 16:53:28 +0000 |
commit | 57a60365da0c47f286ea4608d766abbca5762233 (patch) | |
tree | aaef0948f26f3352092b787d32e1dda0743d697e /synapse/api/errors.py | |
parent | Pull out more info about room key requests (diff) | |
parent | Remove unnecessary abstractions in admin handler (#6751) (diff) | |
download | synapse-github/erikj/debug_direct_message_checks.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/debug_direct_message_checks github/erikj/debug_direct_message_checks erikj/debug_direct_message_checks
Diffstat (limited to 'synapse/api/errors.py')
-rw-r--r-- | synapse/api/errors.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/synapse/api/errors.py b/synapse/api/errors.py index 5853a54c95..1c9456e583 100644 --- a/synapse/api/errors.py +++ b/synapse/api/errors.py @@ -17,13 +17,15 @@ """Contains exceptions and error codes.""" import logging -from typing import Dict +from typing import Dict, List from six import iteritems from six.moves import http_client from canonicaljson import json +from twisted.web import http + logger = logging.getLogger(__name__) @@ -80,6 +82,29 @@ class CodeMessageException(RuntimeError): self.msg = msg +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 + + self.cookies = [] # type: List[bytes] + + class SynapseError(CodeMessageException): """A base exception type for matrix errors which have an errcode and error message (as well as an HTTP status code). @@ -158,12 +183,6 @@ class UserDeactivatedError(SynapseError): ) -class RegistrationError(SynapseError): - """An error raised when a registration event fails.""" - - pass - - class FederationDeniedError(SynapseError): """An error raised when the server tries to federate with a server which is not on its federation whitelist. |