interactor
interactor copied to clipboard
RFC: Nested failures fail, not raise
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.