-
Notifications
You must be signed in to change notification settings - Fork 215
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
.success? still reporting true when interactor invoked via .call is calling internally another interactor with .call! and latter fails #170
Comments
If I understood correctly, this example is trying to fail context in an abnormal way. You're supposed to use the Context API, like
The second issue in this example is that the context object of the parent interactor is not being shared with the nested interactor. Therefore, the context of the parent interactor remains untouched after the call of the nested one (which also doesn't fail context as mentioned in the above example). A more correct version of what you're trying to do would be:
I'd recommend reading the Context class documentation just to clarify what I tried to explain here. |
I think the current way breaks the idea that We ended up adding the following to our interactors: def handle_failures
yield
rescue Interactor::Failure => e
context.fail!(error: e.context.error)
end Sadly we still have to think to wrap every I think it would make more sense to either have the |
I appreciate what @tiagofsilva was getting at about correct usage, but sometimes nesting of Interactors is dynamic, indirect, or generally requires the caller to be aware of the callee's implementation. In #192 I think we have a fix for this and generally unexpected behavior of nested Interactors. |
This behavior is actually dangerous because it's pretty expected that internal Interactor.call! exceptions will be bubbled up to the top, and won't be swallowed. Exceptions might remain unnoticed. +1 for changing the current behavior |
Context
I've noticed in our code base that we had cases where Interactor was encapsulating more interactors and calling them via
.call!
. One of the interactors was raisingInteractor::Failure
exception, but because parent interactor was invoked via.call
context.success?
was still reportingtrue
.I believe that is wrong behavior and since
.call
is not raising exception it at least should returnfalse
when.success?
is invoked.Steps to reproduce
The text was updated successfully, but these errors were encountered: