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

context.fail! is confusing, behaviour has changed, docs haven't #90

Closed
matthucke opened this issue Jun 30, 2015 · 3 comments
Closed

context.fail! is confusing, behaviour has changed, docs haven't #90

matthucke opened this issue Jun 30, 2015 · 3 comments

Comments

@matthucke
Copy link
Contributor

In Version 3, context.fail! always throws an exception:

    # Raises Interactor::Failure initialized with the Interactor::Context.
    def fail!(context = {})
      modifiable.update(context)
      @failure = true
      raise Failure, self
    end

In version 2, it did not. The README is still showing the version 2 behaviour, where the caller queries success? after.

What is the current best practice to indicate and respond to failure? I liked the old idiom of checking context.success? from the controller, after the interactor has returned. Yet now it seems we must rescue instead - a change that disrupts the structure of the controller methods.

Could we provide a non-throwing 'fail' method in addition to the throwing version? (I'm currently using a Rails initializer to monkey-patch one in).

@laserlemon
Copy link
Collaborator

Are you using the class method call or the instance method?

@matthucke
Copy link
Contributor Author

Neither. I was testing internal business-logic methods of my interactor directly - before writing a call that would combine them in sequence.

Reading the source, I discover that call swallows exceptions from fail!, while call! does not.

I'll submit a modification to the README that clarifies this.

[edit] Pull request #91 submitted.

@laserlemon
Copy link
Collaborator

Merged #91.

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

No branches or pull requests

2 participants