summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/directory.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/synapse/storage/directory.py b/synapse/storage/directory.py
index d6a7113b9c..f2e895a5c2 100644
--- a/synapse/storage/directory.py
+++ b/synapse/storage/directory.py
@@ -75,13 +75,18 @@ class DirectoryStore(SQLBaseStore):
         Returns:
             Deferred
         """
-        yield self._simple_insert(
-            "room_aliases",
-            {
-                "room_alias": room_alias.to_string(),
-                "room_id": room_id,
-            },
-        )
+        try:
+            yield self._simple_insert(
+                "room_aliases",
+                {
+                    "room_alias": room_alias.to_string(),
+                    "room_id": room_id,
+                },
+            )
+        except sqlite3.IntegrityError:
+            raise SynapseError(
+                409, "Room alias %s already exists" % room_alias.to_string()
+            )
 
         for server in servers:
             # TODO(erikj): Fix this to bulk insert