summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-04 15:10:27 +0000
committerErik Johnston <erik@matrix.org>2014-11-04 15:10:27 +0000
commit8918422156a3555a61b7e5ba2ee0c04eb3e52cb5 (patch)
tree35c8c3acaf578571a417354feff7c3b7745b3f13 /synapse
parentPEP8 (diff)
downloadsynapse-8918422156a3555a61b7e5ba2ee0c04eb3e52cb5.tar.xz
Move FederationError to synapse.api.errors
Diffstat (limited to 'synapse')
-rw-r--r--synapse/api/errors.py34
-rw-r--r--synapse/types.py34
2 files changed, 34 insertions, 34 deletions
diff --git a/synapse/api/errors.py b/synapse/api/errors.py
index 38ccb4f9d1..33d15072af 100644
--- a/synapse/api/errors.py
+++ b/synapse/api/errors.py
@@ -158,3 +158,37 @@ def cs_error(msg, code=Codes.UNKNOWN, **kwargs):
     for key, value in kwargs.iteritems():
         err[key] = value
     return err
+
+
+class FederationError(RuntimeError):
+    """  This class is used to inform remote home servers about erroneous
+    PDUs they sent us.
+
+    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)
+    """
+
+    def __init__(self, level, code, reason, affected, source=None):
+        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,)
+        super(FederationError, self).__init__(msg)
+
+    def get_dict(self):
+        return {
+            "level": self.level,
+            "code": self.code,
+            "reason": self.reason,
+            "affected": self.affected,
+            "source": self.source if self.source else self.affected,
+        }
diff --git a/synapse/types.py b/synapse/types.py
index 8fac20fd2e..649ff2f7d7 100644
--- a/synapse/types.py
+++ b/synapse/types.py
@@ -128,37 +128,3 @@ class StreamToken(
         d = self._asdict()
         d[key] = new_value
         return StreamToken(**d)
-
-
-class FederationError(RuntimeError):
-    """  This class is used to inform remote home servers about erroneous
-    PDUs they sent us.
-
-    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)
-    """
-
-    def __init__(self, level, code, reason, affected, source=None):
-        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,)
-        super(FederationError, self).__init__(msg)
-
-    def get_dict(self):
-        return {
-            "level": self.level,
-            "code": self.code,
-            "reason": self.reason,
-            "affected": self.affected,
-            "source": self.source if self.source else self.affected,
-        }