return proper error codes for some 404s

pull/4580/head
Hubert Chathi 2019-02-06 17:47:22 -05:00
parent ef43a03fc5
commit 664c81e8b7
1 changed files with 16 additions and 4 deletions

View File

@ -267,7 +267,7 @@ class E2eRoomKeysHandler(object):
version(str): Optional; if None gives the most recent version version(str): Optional; if None gives the most recent version
otherwise a historical one. otherwise a historical one.
Raises: Raises:
StoreError: code 404 if the requested backup version doesn't exist NotFoundError: if the requested backup version doesn't exist
Returns: Returns:
A deferred of a info dict that gives the info about the new version. A deferred of a info dict that gives the info about the new version.
@ -279,7 +279,13 @@ class E2eRoomKeysHandler(object):
""" """
with (yield self._upload_linearizer.queue(user_id)): with (yield self._upload_linearizer.queue(user_id)):
try:
res = yield self.store.get_e2e_room_keys_version_info(user_id, version) res = yield self.store.get_e2e_room_keys_version_info(user_id, version)
except StoreError as e:
if e.code == 404:
raise NotFoundError("Unknown backup version")
else:
raise
defer.returnValue(res) defer.returnValue(res)
@defer.inlineCallbacks @defer.inlineCallbacks
@ -290,8 +296,14 @@ class E2eRoomKeysHandler(object):
user_id(str): the user whose current backup version we're deleting user_id(str): the user whose current backup version we're deleting
version(str): the version id of the backup being deleted version(str): the version id of the backup being deleted
Raises: Raises:
StoreError: code 404 if this backup version doesn't exist NotFoundError: if this backup version doesn't exist
""" """
with (yield self._upload_linearizer.queue(user_id)): with (yield self._upload_linearizer.queue(user_id)):
try:
yield self.store.delete_e2e_room_keys_version(user_id, version) yield self.store.delete_e2e_room_keys_version(user_id, version)
except StoreError as e:
if e.code == 404:
raise NotFoundError("Unknown backup version")
else:
raise