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

Make sure that valid? raises rather than verify #9171

Merged
merged 3 commits into from May 16, 2017

Conversation

ohayon
Copy link
Contributor

@ohayon ohayon commented May 15, 2017

Saw a crash in Stackdriver that showed a lot of failures in the verify method, but it calls into valid? which should be responsible for raising exceptions.

def verify!(value)
UI.user_error!("Invalid value '#{value}' for option '#{self}'") unless valid?(value)
true
true if valid?(value)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I find this a little bit confusing, I think - we have a method ending with a "!" that doesn't explicitly have a raise in it, and a method ending with a "?" that returns either true or else raises an exception.

Feels like the entire body of valid? should be moved into verify!, and the true return value should be eliminated (since it is always true if not raising).

Or am I missing something? 😄

Copy link
Member

Choose a reason for hiding this comment

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

Yes, technically the correct thing to do would be to raise the exception here (method with the !), and only return booleans in valid?. However this would also mean that we can't show specific error messages that are helpful for the user to understand. Maybe we should just have one method that raises the exception?

@ohayon ohayon merged commit e46644e into master May 16, 2017
@ohayon ohayon deleted the fix-config-item-validation branch May 16, 2017 16:47
@fastlane-bot
Copy link

Hey @ohayon 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

@fastlane-bot
Copy link

Congratulations! 🎉 This was released as part of fastlane 2.31.0 🚀

@fastlane fastlane locked and limited conversation to collaborators Aug 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants