diff --git a/src/isolate/connections/grpc/agent.py b/src/isolate/connections/grpc/agent.py index 4dd0149..dd42e90 100644 --- a/src/isolate/connections/grpc/agent.py +++ b/src/isolate/connections/grpc/agent.py @@ -100,23 +100,28 @@ def execute_function( extra_args: Iterable[Any] = (), ) -> Generator[definitions.PartialRunResult, None, Any]: if function.was_it_raised: - raise AbortException( - f"The {function_kind} function must be callable, not a raised exception." + return ( + TypeError( + f"The `{function_kind}` function must be callable, not a raised exception." + ), + True, + None, ) try: # TODO: technically any sort of exception could be raised here, since # depickling is basically involves code execution from the *user*. function = from_grpc(function) - except SerializationError: - yield from self.log(traceback.format_exc(), level=LogLevel.ERROR) - raise AbortException( - f"The {function_kind} function could not be deserialized." - ) + except SerializationError as exc: + return exc, True, traceback.format_exc() if not callable(function): - raise AbortException( - f"The {function_kind} function must be callable, not {type(function).__name__}." + return ( + TypeError( + f"The {function_kind} function must be callable, not {type(function).__name__}." + ), + True, + None, ) yield from self.log(f"Starting the execution of the {function_kind} function.")