When coding a program, there are some rules, and when the rule is violated, the programmer will raise error to report the situation. For instance, let l be a list of integers with length 5, if I call l[5] in my code, then the index error will be raised.
As for details, usually use:
if XXXX:
raise XXXXError
and then define the error in the bottom, the error that is raised is an inheritance of Exception class:
class XXXXError(Exception):
pass
No comments:
Post a Comment