raise
Deliberately raises an error.
Syntax
raise Error("message")Description
In an invalid situation you raise your own error; the calling code can catch it with try/except.
Example
Loading editor…
Expected output
Age cannot be negative
When to use?
Input validation, signaling 'this shouldn't have happened' situations.