Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJohnny Nguyen
3,875 PointsPasan's mistake
if you put the code:
catch VendingMachineError.invalidSelection
then it doesn't work. You have to put into the else clause
Tagging: Pasan Premaratne
1 Answer
rickkettner
8,061 PointsThis isn't a mistake. Here Pasan is using invalidSelection to guard against a non valid selection being passed in to the Vend function. In other words, it's not being used to guard against "no selection".
However, you are correct in that you may also want to add a similar alert in the else clause for when nothing has been selected. Note: This would NOT be triggered by a catch statement though, so I assume he will be addressing this later.