diff --git a/odoo/http.py b/odoo/http.py index 39084570dbf..50845e36130 100644 --- a/odoo/http.py +++ b/odoo/http.py @@ -1785,7 +1785,7 @@ class Dispatcher(ABC): root.set_csp(response) @abstractmethod - def handle_error(self, exc): + def handle_error(self, exc: Exception) -> collections.abc.Callable: """ Transform the exception into a valid HTTP response. Called upon any exception while serving a request. @@ -1828,7 +1828,7 @@ class HttpDispatcher(Dispatcher): else: return endpoint(**self.request.params) - def handle_error(self, exc): + def handle_error(self, exc: Exception) -> collections.abc.Callable: """ Handle any exception that occurred while dispatching a request to a `type='http'` route. Also handle exceptions that occurred @@ -1837,8 +1837,7 @@ class HttpDispatcher(Dispatcher): json. :param Exception exc: the exception that occurred. - :returns: an HTTP error response - :rtype: :class:`werkzeug.wrapper.Response` + :returns: a WSGI application """ if isinstance(exc, SessionExpiredException): session = self.request.session @@ -1914,16 +1913,15 @@ class JsonRPCDispatcher(Dispatcher): result = endpoint(**self.request.params) return self._response(result) - def handle_error(self, exc): + def handle_error(self, exc: Exception) -> collections.abc.Callable: """ Handle any exception that occurred while dispatching a request to a `type='json'` route. Also handle exceptions that occurred when no route matched the request path, that no fallback page could be delivered and that the request ``Content-Type`` was json. - :param exc Exception: the exception that occurred. - :returns: an HTTP error response - :rtype: Response + :param exc: the exception that occurred. + :returns: a WSGI application """ error = { 'code': 200, # this code is the JSON-RPC level code, it is @@ -2132,7 +2130,7 @@ class Application: if 'werkzeug' in config['dev_mode'] and request.dispatcher.routing_type != 'json': raise - # Ensure there is always a Response attached to the exception. + # Ensure there is always a WSGI handler attached to the exception. if not hasattr(exc, 'error_response'): exc.error_response = request.dispatcher.handle_error(exc)