mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-22 17:46:08 +03:00
Better error messages from get_create_event_for_room
(#11638)
"Unknown room" can mean a multitude of things here. To help with debugging, add some more words to the exception text.
This commit is contained in:
parent
8422a7f7f6
commit
bd9821f7f1
2 changed files with 6 additions and 1 deletions
1
changelog.d/11638.misc
Normal file
1
changelog.d/11638.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Improve the error messages from `get_create_event_for_room`.
|
|
@ -177,11 +177,15 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
|
|||
NotFoundError if the room is unknown
|
||||
"""
|
||||
state_ids = await self.get_current_state_ids(room_id)
|
||||
|
||||
if not state_ids:
|
||||
raise NotFoundError(f"Current state for room {room_id} is empty")
|
||||
|
||||
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:
|
||||
raise NotFoundError("Unknown room %s" % (room_id,))
|
||||
raise NotFoundError(f"No create event in current state for room {room_id}")
|
||||
|
||||
# Retrieve the room's create event and return
|
||||
create_event = await self.get_event(create_id)
|
||||
|
|
Loading…
Reference in a new issue