From e378832922d0e60a49d3fbb780f29ca4a74a8c91 Mon Sep 17 00:00:00 2001 From: Alessio Renda Date: Wed, 14 Feb 2024 12:35:30 +0100 Subject: [PATCH] [IMP] rest_log: add MissingError to dispatch method --- rest_log/components/service.py | 9 +++++++++ rest_log/exceptions.py | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/rest_log/components/service.py b/rest_log/components/service.py index 354bfe178..bbb45503f 100644 --- a/rest_log/components/service.py +++ b/rest_log/components/service.py @@ -17,6 +17,7 @@ from ..exceptions import ( RESTServiceDispatchException, + RESTServiceMissingErrorException, RESTServiceUserErrorException, RESTServiceValidationErrorException, ) @@ -43,6 +44,14 @@ def _dispatch_with_db_logging(self, method_name, *args, params=None): try: with self.env.cr.savepoint(): result = super().dispatch(method_name, *args, params=params) + except exceptions.MissingError as orig_exception: + self._dispatch_exception( + method_name, + RESTServiceMissingErrorException, + orig_exception, + *args, + params=params, + ) except exceptions.ValidationError as orig_exception: self._dispatch_exception( method_name, diff --git a/rest_log/exceptions.py b/rest_log/exceptions.py index 700cf6aa7..d2ebc0f9b 100644 --- a/rest_log/exceptions.py +++ b/rest_log/exceptions.py @@ -13,6 +13,12 @@ def __init__(self, message, log_entry_url): self.rest_json_info = {"log_entry_url": log_entry_url} +class RESTServiceMissingErrorException( + RESTServiceDispatchException, odoo_exceptions.MissingError +): + """Missing error wrapped exception.""" + + class RESTServiceUserErrorException( RESTServiceDispatchException, odoo_exceptions.UserError ):