Skip to content

Commit

Permalink
rest_log: fix _dispatch_exception
Browse files Browse the repository at this point in the history
Fix regression caused by OCA/pull/147.
Unfortunately there's no 100% test cov.

I'm gonna fix this soon.
  • Loading branch information
simahawk committed Jan 20, 2022
1 parent 13658e0 commit eb19b16
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions rest_log/components/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,27 @@ def _dispatch_with_db_logging(self, method_name, *args, params=None):
result = super().dispatch(method_name, *args, params=params)
except exceptions.UserError as orig_exception:
self._dispatch_exception(
RESTServiceUserErrorException, orig_exception, *args, params=params
method_name,
RESTServiceUserErrorException,
orig_exception,
*args,
params=params,
)
except exceptions.ValidationError as orig_exception:
self._dispatch_exception(
method_name,
RESTServiceValidationErrorException,
orig_exception,
*args,
params=params,
)
except Exception as orig_exception:
self._dispatch_exception(
RESTServiceDispatchException, orig_exception, *args, params=params
method_name,
RESTServiceDispatchException,
orig_exception,
*args,
params=params,
)
log_entry = self._log_call_in_db(
self.env, request, method_name, *args, params=params, result=result
Expand All @@ -64,7 +73,9 @@ def _dispatch_with_db_logging(self, method_name, *args, params=None):
result["log_entry_url"] = log_entry_url
return result

def _dispatch_exception(self, exception_klass, orig_exception, *args, params=None):
def _dispatch_exception(
self, method_name, exception_klass, orig_exception, *args, params=None
):
tb = traceback.format_exc()
# TODO: how to test this? Cannot rollback nor use another cursor
self.env.cr.rollback()
Expand All @@ -73,6 +84,7 @@ def _dispatch_exception(self, exception_klass, orig_exception, *args, params=Non
log_entry = self._log_call_in_db(
env,
request,
method_name,
*args,
params=params,
traceback=tb,
Expand Down

0 comments on commit eb19b16

Please sign in to comment.