Skip to content

Conversation

@dmee3
Copy link

@dmee3 dmee3 commented May 19, 2017

def edit_beer
id = Print::get_input("\nEnter the id of the beer you want to EDIT:").to_i
b = @beerList.find_beer id
fail "No beer matching id #{id}" unless b
Copy link
Member

Choose a reason for hiding this comment

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

Both calls to find_beer fail when they don't get a result. Should find_beer be responsible for failing when it doesn't find one?

Copy link
Author

Choose a reason for hiding this comment

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

You're right, find_beer should probably handle its own failure so there's a single point of failure instead of having to repeat this logic here and in edit_beer on line 41 of the model.

I guess the only reason to return nil and check outside find_beer would be if I wanted to do some other error handling instead of failing right away, which I didn't do anyway haha.

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.

2 participants