summary refs log tree commit diff
path: root/synapse/api/errors.py
diff options
context:
space:
mode:
authorDavid Baker <dbkr@users.noreply.github.com>2017-05-03 11:23:25 +0100
committerGitHub <noreply@github.com>2017-05-03 11:23:25 +0100
commit60833c8978d9f25c2d6c59c809c9b14a8f7e89e7 (patch)
tree1678fc6711c54fecfe94b4608f47a2f6d4ff5529 /synapse/api/errors.py
parentMerge pull request #2175 from matrix-org/erikj/prefill_state (diff)
parentNo need for the exception variable (diff)
downloadsynapse-60833c8978d9f25c2d6c59c809c9b14a8f7e89e7.tar.xz
Merge pull request #2147 from matrix-org/dbkr/http_request_propagate_error
Propagate errors sensibly from proxied IS requests
Diffstat (limited to 'synapse/api/errors.py')
-rw-r--r--synapse/api/errors.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/synapse/api/errors.py b/synapse/api/errors.py
index 6fbd5d6876..d0dfa959dc 100644
--- a/synapse/api/errors.py
+++ b/synapse/api/errors.py
@@ -66,6 +66,17 @@ class CodeMessageException(RuntimeError):
         return cs_error(self.msg)
 
 
+class MatrixCodeMessageException(CodeMessageException):
+    """An error from a general matrix endpoint, eg. from a proxied Matrix API call.
+
+    Attributes:
+        errcode (str): Matrix error code e.g 'M_FORBIDDEN'
+    """
+    def __init__(self, code, msg, errcode=Codes.UNKNOWN):
+        super(MatrixCodeMessageException, self).__init__(code, msg)
+        self.errcode = errcode
+
+
 class SynapseError(CodeMessageException):
     """A base exception type for matrix errors which have an errcode and error
     message (as well as an HTTP status code).