Raise Statements
The raise
flow control statement will terminate the current scope by raising (or re-raising) an exception. The exception will bubble up the call stack, terminating all execution flow, until it is caught by a try
/except
block.
The raise
keyword can be used in two ways.
Typically, raise
is followed by an expression that provides an exception instance. That instance (typically of type Exception
or a sub-type, but any Object can be raised, in theory) will travel up the stack, and will be available to all exception handlers, providing details about the exception that occurred.
Inside a try
/except
block, the raise
keyword can be used on its own; it will the re-raise the exception currently being handled.
raise new ArgumentException('Invalid parameter!');