diff options
author | reivilibre <oliverw@matrix.org> | 2021-12-13 15:39:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-13 15:39:43 +0000 |
commit | e5cdb9e2339e321e8a77a898d362d7fbc476303b (patch) | |
tree | 7ddb175af84267fd6e1cfb547346a7358a214fb5 /synapse/rest/client | |
parent | Allow events to be created with no `prev_events` (MSC2716) (#11243) (diff) | |
download | synapse-e5cdb9e2339e321e8a77a898d362d7fbc476303b.tar.xz |
Make `get_device` return None if the device doesn't exist rather than raising an exception. (#11565)
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
Diffstat (limited to 'synapse/rest/client')
-rw-r--r-- | synapse/rest/client/devices.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/rest/client/devices.py b/synapse/rest/client/devices.py index 8566dc5cb5..ad6fd6492b 100644 --- a/synapse/rest/client/devices.py +++ b/synapse/rest/client/devices.py @@ -17,6 +17,7 @@ import logging from typing import TYPE_CHECKING, Tuple from synapse.api import errors +from synapse.api.errors import NotFoundError from synapse.http.server import HttpServer from synapse.http.servlet import ( RestServlet, @@ -24,10 +25,9 @@ from synapse.http.servlet import ( parse_json_object_from_request, ) from synapse.http.site import SynapseRequest +from synapse.rest.client._base import client_patterns, interactive_auth_handler from synapse.types import JsonDict -from ._base import client_patterns, interactive_auth_handler - if TYPE_CHECKING: from synapse.server import HomeServer @@ -116,6 +116,8 @@ class DeviceRestServlet(RestServlet): device = await self.device_handler.get_device( requester.user.to_string(), device_id ) + if device is None: + raise NotFoundError("No device found") return 200, device @interactive_auth_handler |