课程: Programming Concepts for Python
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Customize errors
(breaker box cover clanging) - With the breaker back on, I can try the dishwasher again. - Barron, we have another problem. The dishwasher's spewing water everywhere. - Uh-oh. Well, this is a new type of issue. I know how to handle electrical problems, but I don't know how to stop an out of control dishwasher. When handling errors, it's very important that I consider the type of error that's occurred. If it's an error I'm able to handle, then I can take some appropriate action to deal with it. On the other hand, there may be types of errors that I'm not prepared to handle, like a raging dishwasher. In that case, I can pass the error information on to somebody else that is able to handle it. I need to call a plumber. - [Olivia] Many programming languages include built-in error types for many commonly occurring exceptions. For example, if I try to divide by zero, Python will raise an exception of the type ZeroDivisionError.…