Skip to content

Multiple kinds of failure #165

@benthorner

Description

@benthorner

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions