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

Python

Exceptions vs Raising Exceptions.

I'm going through the Python learning track and I'm understanding that you write an exception if there is a possibility that the input from the user will be invalid. The next video I'm watching talks about when to raise an exception, but what is "raising an exception" really? What would make you consider raising an exception versus just making a single exception?

1 Answer

Josh Keenan
Josh Keenan
19,652 Points

Raising an exception means that you aren't just handling it, but raising an error to inform the user that there was in fact an error and whatever they did wasn't allowed. Using except, we can handle errors quietly without the user being aware of it, unless we raise the exception, hope this helps.