Skip to content

Propagating exceptions from executed actions #371

@kshalot

Description

@kshalot

Hello!

Issue

I noticed that whenever an action fails, regardless of the cause, the exception is always silenced and logged with a simple print. I traced the implementation and found that this behaviour is controlled by the following logic:

Current API

The exceptions are only re-raised if the following conditions are met:

if not catch_exceptions and exception:
raise exception

I traced the code and the catch_exceptions flag is set to True by default:

def run(fun_one: Callable, fun_many: Optional[Callable], data: Union[Resource, List[Resource]],
exception: Type[RunException], id_required: bool = False,
required_synchronized: Optional[bool] = None, execute_actions: bool = False,
monitored_status: Optional[str] = None, catch_exceptions: bool = True, **kwargs) -> None:

And there seems to be no way to change it's value, since the public API of the Store does not allow for this argument to be passed, for example:

def register(
self, data: Union[Resource, List[Resource]], schema_id: str = None
) -> None:
# Replace None by self._register_many to switch to optimized bulk registration.
run(
self._register_one,
None,
data,
required_synchronized=False,
execute_actions=True,
exception=RegistrationError,
monitored_status="_synchronized",
schema_id=schema_id,
)

Is there something I'm missing or is there currently no way to allow the exceptions to propagate normally? Is this a conscious decision? I found that #281 adds a way to manipulate this behaviour, although only for "debug" purposes and the PR is not merged.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions