Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Nested failures fail, not raise #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

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.

1 participant