From 9154187d85a653e8fb2ae7fba8ae36bae43046e6 Mon Sep 17 00:00:00 2001 From: Gabriel Guarisa Date: Tue, 10 Sep 2024 16:09:36 -0300 Subject: [PATCH] Add raise_raw_exception param to execute method --- pyproject.toml | 2 +- retrack/engine/executor.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b94c58d..3ca9b00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "retrack" -version = "2.9.0a2" +version = "2.9.0a3" description = "A business rules engine" authors = ["Gabriel Guarisa "] license = "MIT" diff --git a/retrack/engine/executor.py b/retrack/engine/executor.py index 1f83538..0202670 100644 --- a/retrack/engine/executor.py +++ b/retrack/engine/executor.py @@ -204,6 +204,7 @@ def execute( self, payload_df: pd.DataFrame, debug_mode: bool = False, + raise_raw_exception: bool = False, context: typing.Optional[registry.Registry] = None, ) -> typing.Union[ pd.DataFrame, typing.Tuple[Execution, typing.Optional[Exception]] @@ -213,6 +214,7 @@ def execute( Args: payload_df (pd.DataFrame): The payload to be executed. debug_mode (bool, optional): If True, runs the rule in debug mode and returns the exception, if any. Defaults to False. + raise_raw_exception (bool, optional): If True, raises the raw exception. Defaults to False. context (registry.Registry, optional): Global constants to be used during execution. Defaults to None. Raises: @@ -240,6 +242,9 @@ def execute( try: self.__run_node(node_id, execution=execution) except Exception as e: + if raise_raw_exception: + raise e + msg = None if isinstance(e, exceptions.ExecutionException): msg = "Error executing a sub-rule node {} from rule {} version {}".format(