Skip to content

Conversation

@exterm
Copy link

@exterm exterm commented Oct 30, 2023

We've been using this library for years, but only recently started adopting call! for fast failures.

We found that the behavior of a nested call! vs a fail! was surprising.

E.g.

class SomeInteractor
  include Interactor
  
  def call
    context.fail!
  end
end

SomeInteractor.tap(&:call).failure?

# => true

But,

class NestedInteractor
  include Interactor
  
  def call
    context.fail!
  end
end

class SomeInteractor
  include Interactor
  
  def call
    NestedInteractor.call!
  end
end

SomeInteractor.tap(&call).failure?
# raises Interactor::Failure exception

We would have expected that SomeInteractor.call shows the same behavior in both cases, catching Failure and returning a context with failure status.

I've attached a (very rough) example implementation in this PR.

@dgmora
Copy link

dgmora commented May 26, 2025

@gaffneyc I've been running the last released version and I had some issues with nested interactors. If you use call! inside of the call of an interactor, when the inner interactor fails, the Interactor::Failure gets swallowed and the outer call succeeds.

With #170 it's a bit better, Interactor::Failure is raised. I would expect however, that it behaves as if fail! is called. I've tried this PR and it behaves as I would expect. Is this something that you could consider adding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants