diff --git a/sat/plugins/plugin_comp_ap_gateway/__init__.py b/sat/plugins/plugin_comp_ap_gateway/__init__.py index e4b77543..fa0e1b2f 100644 --- a/sat/plugins/plugin_comp_ap_gateway/__init__.py +++ b/sat/plugins/plugin_comp_ap_gateway/__init__.py @@ -474,7 +474,7 @@ class APGateway: try: found_item = found_items[0] except IndexError: - raise exceptions.NotFound("requested items can't be found") + raise exceptions.NotFound(f"requested item at {url} can't be found") if node.startswith(self._events.namespace): # this is an event diff --git a/sat/plugins/plugin_comp_ap_gateway/http_server.py b/sat/plugins/plugin_comp_ap_gateway/http_server.py index dd7040e8..6ca81af3 100644 --- a/sat/plugins/plugin_comp_ap_gateway/http_server.py +++ b/sat/plugins/plugin_comp_ap_gateway/http_server.py @@ -78,14 +78,24 @@ class HTTPAPGServer(web_resource.Resource): request.setResponseCode(http_code, None if msg is None else msg.encode()) def _onRequestError(self, failure_: failure.Failure, request: "HTTPRequest") -> None: - log.exception(f"Internal error: {failure_.value}") - self.responseCode( - request, - http.INTERNAL_SERVER_ERROR, - f"internal error: {failure_.value}" - ) + exc = failure_.value + if isinstance(exc, exceptions.NotFound): + self.responseCode( + request, + http.NOT_FOUND, + str(exc) + ) + else: + log.exception(f"Internal error: {failure_.value}") + self.responseCode( + request, + http.INTERNAL_SERVER_ERROR, + f"internal error: {failure_.value}" + ) + request.finish() + raise failure_ + request.finish() - raise failure_ async def webfinger(self, request): url_parsed = parse.urlparse(request.uri.decode())