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

Failure modes/types #6

Open
taylorthurlow opened this issue Oct 31, 2020 · 0 comments
Open

Failure modes/types #6

taylorthurlow opened this issue Oct 31, 2020 · 0 comments
Assignees
Labels
discussion Something to discuss enhancement New feature or request
Milestone

Comments

@taylorthurlow
Copy link
Owner

Similar to collectiveidea/interactor#165, it might be nice to support a way to fail an interaktor with a particular type. It could be that the desire for multiple failure types is a symptom of having interaktors which are too complicated, but I'm leaning towards that not necessarily being true. If this were to be implemented I could see a new symbol argument being added to #fail! which represents the failure mode.

Take for example an interaktor which is invoked when a web request is received by an API. The interaktor is designed to create a new record in a database. That record may fail validation, or perhaps the record already exists. Typically error handling would be different between these two cases - maybe the API endpoint wants to send the right HTTP response code.

fail!(:validation, errors: record.errors)
fail!(:duplication, error: "The record already exists.")

It could also be useful to define these failure modes on the interaktor definition:

failure_mode :validation, :duplication

This would also aid in generating methods to check the error type, like #validation_error? or #duplication_error? in the example above. If they are defined, then specifying one when calling #fail! would be required.

@taylorthurlow taylorthurlow added enhancement New feature or request discussion Something to discuss labels Oct 31, 2020
@taylorthurlow taylorthurlow added this to the 1.0 milestone Oct 31, 2020
@taylorthurlow taylorthurlow self-assigned this Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Something to discuss enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant