summary refs log tree commit diff
path: root/synapse/storage/state.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2019-01-31 18:34:15 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2019-01-31 18:34:15 +0000
commitd239f67c25a31257a11852be08e6615e99423fe7 (patch)
tree517da58f496449c5f1d347ad72d82a11022c176d /synapse/storage/state.py
parentNew function for getting room's create event (diff)
downloadsynapse-d239f67c25a31257a11852be08e6615e99423fe7.tar.xz
Raise an exception instead of returning None
Diffstat (limited to '')
-rw-r--r--synapse/storage/state.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py
index 522aaee918..d14a7b2538 100644
--- a/synapse/storage/state.py
+++ b/synapse/storage/state.py
@@ -24,6 +24,7 @@ import attr
 from twisted.internet import defer
 
 from synapse.api.constants import EventTypes
+from synapse.api.errors import NotFoundError
 from synapse.storage._base import SQLBaseStore
 from synapse.storage.background_updates import BackgroundUpdateStore
 from synapse.storage.engines import PostgresEngine
@@ -442,6 +443,9 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
 
         Returns:
             Deferred[unicode|None]: predecessor room id
+
+        Raises:
+            NotFoundError if the room is unknown
         """
         # Retrieve the room's create event
         create_event = yield self.get_create_event_for_room(room_id)
@@ -457,14 +461,17 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
             room_id (str)
 
         Returns:
-            Deferred[EventBase|None]: The room creation event. None if can not be found
+            Deferred[EventBase]: The room creation event.
+
+        Raises:
+            NotFoundError if the room is unknown
         """
         state_ids = yield self.get_current_state_ids(room_id)
         create_id = state_ids.get((EventTypes.Create, ""))
 
         # If we can't find the create event, assume we've hit a dead end
         if not create_id:
-            defer.returnValue(None)
+            raise NotFoundError("Unknown room %s" % (room_id))
 
         # Retrieve the room's create event and return
         create_event = yield self.get_event(create_id)