So we just created a program that isn't going to air out, hopefully at least with Vallieres and Zero
Division airs.
But sometimes errors and exceptions can be so severe that we do want to stop our programs from running.
We do want to catch them like this with the block, but at the same time also stop whatever the program
is doing.
Maybe instead of print, we actually want to display that red here and says, oh, something bad's happening.
Stop that.
Well, in that case, we either don't use the except block or in here we can say raise.
Value air.
Now, this is rare that you would have to do this.
There are some specific use cases, but here you just write a message saying, hey.
Cut it out so that if I run this.
Well, if I type in a valid number, I get please enter a number, OK, I'm finally done because I raise
a value error.
And it throws in here into the book, so I'd have to remove this and if I remove this like this and
hit Ron.
And five and look at that, I get a value error, hey, cut it up so I'm able to throw my own eres.
So this is really useful if you're creating your own library or tool and you want to let the user know
that an error happened, I'm not going to keep doing what you're doing.
And this could be any type of error, you can also do something like exception, and if I click run
here, do five.
I get an exception.
Hey, cut it up.
The key thing to remember with Ayres is that errors are unavoidable in programming, what your job is
as a programmer is to be able to anticipate these errors, these bugs, these exceptions, and handle
them properly in your programs.
And some of the biggest errors happen when we're trying to accept input from a user not just using this
input, but functions, accepting arguments, classes, accepting different inputs from users like method
calls and trying to change attributes when the outside world in our programs try to communicate with
each other.
Errors are bound to happen.
Our job as programmers is to try and code in a way that handles these exceptions gracefully and we can
anticipate these.
Sayres there's no such thing as a perfect program.
However, we can try and do our best to learn from these errors and try to manage them so that our programs
don't break.
I'll see you in the next one.