I want to be able to do something like this, but Flow just errors out when my step that Flow “returns” outputs {:error, reason} rather than returning :ok or :error tuples. Is there a way to make this work?
MyFlow.run()
|> case do
{:ok, _} -> "success"
{:error, reason} -> reason
end
The documentation states this, so it doesn’t sound like it returns an error tuple. (I will be happy to be wrong)
Currently, any error anywhere in the flow will fail the flow and will return an error. Over time, error handling behavior will be added,
Error stacktrace
[error] GenServer #PID<0.12304.0> terminating
** (Ash.Error.Unknown) Unknown Error
* Oops, there was an error.
at update_task_instance_status_transaction, create_instance_approval
(ash 2.17.7) lib/ash/error/error.ex:391: Ash.Error.to_ash_error/3
(ash 2.17.7) lib/ash/engine/request.ex:228: Ash.Engine.Request.next/1
(ash 2.17.7) lib/ash/engine/engine.ex:712: Ash.Engine.advance_request/2
(ash 2.17.7) lib/ash/engine/engine.ex:637: Ash.Engine.fully_advance_request/2
(ash 2.17.7) lib/ash/engine/engine.ex:578: Ash.Engine.do_run_iteration/2
(elixir 1.15.5) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
(ash 2.17.7) lib/ash/engine/engine.ex:307: Ash.Engine.run_to_completion/1
(ash 2.17.7) lib/ash/engine/engine.ex:252: Ash.Engine.do_run/2
(ash 2.17.7) lib/ash/engine/engine.ex:114: anonymous fn/3 in Ash.Engine.run/2
(ash 2.17.7) lib/ash/data_layer/data_layer.ex:337: Ash.DataLayer.transaction/4
(ash 2.17.7) lib/ash/data_layer/data_layer.ex:322: anonymous fn/5 in Ash.DataLayer.transaction/4
(ash 2.17.7) lib/ash/data_layer/data_layer.ex:337: Ash.DataLayer.transaction/4
(ash 2.17.7) lib/ash/data_layer/data_layer.ex:322: anonymous fn/5 in Ash.DataLayer.transaction/4
(ash 2.17.7) lib/ash/data_layer/data_layer.ex:337: Ash.DataLayer.transaction/4
(ash 2.17.7) lib/ash/data_layer/data_layer.ex:322: anonymous fn/5 in Ash.DataLayer.transaction/4
(ecto_sql 3.11.0) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
(db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
(ash 2.17.7) lib/ash/flow/flow.ex:26: Ash.Flow.run!/3