The return function of this wrapper should be outside the
try since the exception handling is solely for the resolving of the PID.
Instead the correct way to do it would be:
def inner(self, pid_value, *args, **kwargs):
try:
pid, record = request.view_args['pid_value'].data
except SQLAlchemyError:
raise PIDResolveRESTError(pid_value)
return f(self, pid=pid, record=record, *args, **kwargs)
return inner
After this change is performed the test test_delete_with_sqldatabase_error will start failing since the Exception is not handled then.