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

Add helpful error message when not returning a Dry::Monads::Result from step #16

Conversation

cllns
Copy link
Member

@cllns cllns commented Jun 20, 2024

When using dry-operation for the first time, I had a method with an if statement without an else, so it was returning nil when the condtion wasn't true. This messes up the step method because it always needs either a Dry::Monads::Result::Success or a Dry::Monads::Result::Failure object.

The error I was seeing was:

NoMethodError: undefined method `value_or' for nil

And (I think due to how we prepend the methods in this gem) there was no error pointing to dry-operation at all, the only stacktrace lines were within my app.

Copy link
Member

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cllns, this is a very helpful addition. Just leaving a suggestion.

@timriley
Copy link
Member

timriley commented Jun 21, 2024

Looks good to me, once @waiting-for-dev's suggestion is done. 👍🏼 Thanks @cllns!

@cllns
Copy link
Member Author

cllns commented Jun 22, 2024

All set 🫡

Copy link
Member

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @cllns 🙌

@waiting-for-dev waiting-for-dev merged commit 2b98e04 into dry-rb:main Jun 22, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants