Hello all,
I have been dipping my toes in Reactor recently, but I am sort of stuck on the Error Handling with Compensation.
In Step 6,
# Test with a valid @example.com email (should succeed)
{:ok, user} = Reactor.run(ResilientUserRegistration, %{
email: "alice@example.com",
password: "secretpassword123"
})
In step 5, the tutorial defines a :send_admin_notification
step that utilizes EmailService
to simulate sending an email to “admin@company.com”. However, EmailService
is set up to fail for any email address that doesn’t end with “@example.com”. Wouldn’t the Reactor eventually fail regardless of the entered email address? For reference, this is what I get when I run the step:
{:error,
%Reactor.Error.Invalid{
errors: [
%Reactor.Error.Invalid.RunStepError{
error: %{message: "Email service unavailable", type: :network_timeout},
step: %Reactor.Step{
arguments: [
%Reactor.Argument{
description: nil,
name: :user,
source: %Reactor.Template.Result{name: :create_user, sub_path: []},
transform: nil
},
%Reactor.Argument{
description: nil,
name: :email,
source: %Reactor.Template.Value{
value: "admin@company.com",
sub_path: []
},
transform: nil
}
],
async?: true,
context: %{},
description: nil,
impl: {EmailService, []},
name: :send_admin_notification,
max_retries: 1,
ref: :send_admin_notification,
transform: nil,
guards: []
},
splode: Reactor.Error,
bread_crumbs: [],
vars: [],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :invalid
}
],
splode: Reactor.Error,
bread_crumbs: [],
vars: [],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :unknown
}}
Thank you!