I am using an Ash Reactor as the implementation for a Resource Action (using run MyReactor). I want to return a simple error atom or a specific tuple from a Reactor step (e.g., {:error, :invalid_token}) and have that atom be easily accessible in my controller or LiveView.
When a step in the Reactor returns an error tuple, Ash wraps the result in a nested %Ash.Error.Unknown struct. Instead of being able to pattern match on the atom I provided, my error value is converted into a string and buried inside a RunStepError message.
Here is a simplified version of my Reactor step:
# Inside an Ash.Reactor module
step :verify_token do
argument :token_record, result(:get_token)
run fn %{token_record: token}, _ ->
if is_nil(token) do
# I want to return this cleanly
{:error, :invalid_token}
else
{:ok, token}
end
end
end
When I call the action via the Domain Code Interface, I receive error in this format:
{:error,
%Ash.Error.Unknown{
errors: [
%Ash.Error.Unknown.UnknownError{
error: "** (Reactor.Error.Invalid) \nInvalid Error\n\n* # Run Step Error\n\n ... ## `error`:\n\n`:invalid_token` ..."
}
]
}}
-
Is there a way to return an error from a Reactor step that Ash will recognize as a first-class error (like
Ash.Error.Invalid) rather than anUnknownerror? -
What is the recommended pattern for identifying specific “business logic” failures from a Reactor without parsing the error string or digging through the nested
Reactor.Error.Invalidstructs?






















