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

Multiple kinds of failure #165

Open
benthorner opened this issue Mar 22, 2019 · 0 comments
Open

Multiple kinds of failure #165

benthorner opened this issue Mar 22, 2019 · 0 comments

Comments

@benthorner
Copy link

We're looking at using Interactor to refactor our controllers. One of the nice things is the clear separation of code to handle success? and failed? cases.

Sometimes we may have interactors that can fail in multiple ways, where the code to handle the failed? case might be different, depending on the kind of failure.

One way of approaching this might be like this:

# in the interactor
context.fail(error: :error_type_1)

# in the controller
if result.failed? && result.error == :error_type_1
   # handle this kind of error e.g. render instead of redirect

It would be convenient if you could do something like if result.failed?(error: :error_type_1). Would you consider adding such a feature to the gem?

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

1 participant