From 68fef14c182e02a855d2d0fbedd518d41411d41b Mon Sep 17 00:00:00 2001 From: Elias Arruda Date: Fri, 24 Jan 2025 12:25:16 -0300 Subject: [PATCH] Revert "error inside invoke action" This reverts commit b5ca9256068abd8c5a05c2250cd7690b500d172d. --- lib/actors/actor/caller_consumer.ex | 27 ++++++++----------- spawn_sdk/spawn_sdk/test/actor/actor_test.exs | 22 --------------- 2 files changed, 11 insertions(+), 38 deletions(-) diff --git a/lib/actors/actor/caller_consumer.ex b/lib/actors/actor/caller_consumer.ex index 68829e78..d3b28b15 100644 --- a/lib/actors/actor/caller_consumer.ex +++ b/lib/actors/actor/caller_consumer.ex @@ -618,28 +618,23 @@ defmodule Actors.Actor.CallerConsumer do end end) rescue - error -> - Logger.error(Exception.format(:error, error, __STACKTRACE__)) - - {:error, :actor_invoke, error} - catch - :exit, error -> - # no need to log because this is already logged by the system - {:error, :actor_invoke, error} + e -> + Logger.error( + "Failure to make a call to actor #{inspect(actor.id.name)} #{inspect(e)}" + ) + + reraise e, __STACKTRACE__ end |> case do - :error = result -> + result = :error -> {:cont, result} - {:error, :action_not_found, _msg} = result -> - {:halt, result} - - {:error, :actor_invoke, error} -> - {:halt, {:error, error}} - - {:error, _msg} = result -> + result = {:error, msg} -> {:cont, result} + result = {:error, :action_not_found, msg} -> + {:halt, result} + result -> {:halt, result} end diff --git a/spawn_sdk/spawn_sdk/test/actor/actor_test.exs b/spawn_sdk/spawn_sdk/test/actor/actor_test.exs index 28ce8839..dff4d94f 100644 --- a/spawn_sdk/spawn_sdk/test/actor/actor_test.exs +++ b/spawn_sdk/spawn_sdk/test/actor/actor_test.exs @@ -40,13 +40,6 @@ defmodule Actor.ActorTest do |> Value.void() end) - action("test_error", fn _ctx, _payload -> - # match error - 1 = 2 - - Value.of() - end) - action("sum", fn %Context{} = ctx, %MyMessageRequest{id: id, data: data} -> current_state = ctx.state new_state = current_state @@ -415,21 +408,6 @@ defmodule Actor.ActorTest do end describe "invoke with routing" do - test "simple match error inside an action", ctx do - system = ctx.system - - dynamic_actor_name = "#{inspect(make_ref())}" <> "simple_error" - - assert {:ok, response} = - SpawnSdk.invoke(dynamic_actor_name, - ref: "my_actor_ref", - system: system, - action: "test_error" - ) - - assert {:error, _} = response - end - test "simple call that goes through 3 actors piping each other", ctx do system = ctx.system