Raising Your Own Exceptions

A function that's handed a value that makes no sense should refuse it with raise and a message that says what was wrong, can name its own kind of error with a small exception class, and raises rather than returning None when carrying on would give a wrong answer.

By

Updated

Cheat sheet: Raising Your Own Exceptions
Category
Python
Level
Journeyman
Tags
Built-in Exceptions, Custom Exception (python), None, python, raise