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 trial

C# C# Objects Inheritance Catching Exceptions

Sean Flanagan
Sean Flanagan
33,235 Points

Catching Exceptions quiz, Question 3

Why is the answer to this question:

catch(TreehouseDefense.TreehouseDefenseException ex)

It's just that catch(System.Exception ex) handles more general errors and there was no catch(TreehouseDefense.TreehouseDefenseException ex) in the code block.

1 Answer

Steven Parker
Steven Parker
231,198 Points

This one doesn't have quite enough information in the question, it depends on you recalling some of the lesson. In particular, you need to know (or guess) that OutOfBoundsException is derived from TreehouseDefenseException.

With that relationship in mind, the correct answer should make sense. But otherwise I agree that System.Exception would be the correct answer.

You might want to report this lack of clarity as a bug to the Support staff.