Skip to content

Commit

Permalink
feat(agent): return more exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Apr 26, 2024
1 parent 3b13546 commit ef30ef9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/isolate/connections/grpc/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit ef30ef9

Please sign in to comment.