summary refs log tree commit diff
path: root/synapse/api/errors.py
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2018-08-17 13:33:54 +0000
committerGitHub <noreply@github.com>2018-08-17 13:33:54 +0000
commit4c22b4047b53e36303c3513e21b3ba9b12ca14ce (patch)
treef0439ed7a668a2b0d627b78aaab25b03a2fb6514 /synapse/api/errors.py
parentMerge pull request #3708 from matrix-org/neilj/resource_Limit_block_event_cre... (diff)
parentMerge branch 'neilj/limit_exceeded_error' of github.com:matrix-org/synapse in... (diff)
downloadsynapse-4c22b4047b53e36303c3513e21b3ba9b12ca14ce.tar.xz
Merge pull request #3707 from matrix-org/neilj/limit_exceeded_error
add new error type ResourceLimit
Diffstat (limited to 'synapse/api/errors.py')
-rw-r--r--synapse/api/errors.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/synapse/api/errors.py b/synapse/api/errors.py
index 08f0cb5554..e26001ab12 100644
--- a/synapse/api/errors.py
+++ b/synapse/api/errors.py
@@ -224,15 +224,34 @@ class NotFoundError(SynapseError):
 
 class AuthError(SynapseError):
     """An error raised when there was a problem authorising an event."""
-    def __init__(self, code, msg, errcode=Codes.FORBIDDEN, admin_uri=None):
+
+    def __init__(self, *args, **kwargs):
+        if "errcode" not in kwargs:
+            kwargs["errcode"] = Codes.FORBIDDEN
+        super(AuthError, self).__init__(*args, **kwargs)
+
+
+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
+    """
+    def __init__(
+        self, code, msg,
+        errcode=Codes.RESOURCE_LIMIT_EXCEED,
+        admin_uri=None,
+        limit_type=None,
+    ):
         self.admin_uri = admin_uri
-        super(AuthError, self).__init__(code, msg, errcode=errcode)
+        self.limit_type = limit_type
+        super(ResourceLimitError, self).__init__(code, msg, errcode=errcode)
 
     def error_dict(self):
         return cs_error(
             self.msg,
             self.errcode,
             admin_uri=self.admin_uri,
+            limit_type=self.limit_type
         )