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 trialshawn007
15,408 PointsThrowing Exceptions
How come, in the Throwing Exceptions video, we are using exception twice? I would assume that MapLocation.cs is already using the exception which should work anyway in the try/catch.
2 Answers
Steven Parker
231,269 PointsAt what time point(s) in the video do you see "using exception twice"?
Philipp Räse
Courses Plus Student 10,298 PointsThrowing an exception may have multiple reasons.
In our case, we want to throw the first exception in our constructor to interrupt the creation of the object, because throwing an exception interrupts everything else and we really don't want any behaviour outside of our map. ;-)
In addition, we use the try/catch block to establish a defined system behavior in case of exception (output of a message box, ...).