Contents | Prev | Next | Index


Raise Statements

An exception is raised using the raise statement. This process is also known as throwing an exception.

raise_stmt         ::= RAISE exception_instance
                   ::= RAISE                   
exception_instance ::= expr

The argument to a raise statement must be an object. In other words, the RAISE keyword must be followed by an expression of a class type. When an exception is raised, the exception handling logic takes ownership of the exception object. Once the exception has been handled, the exception object gets automatically destroyed.

A raise statement raises an object, not a class. The argument of the raise statement is an instance of an exception class and is typically constructed 'on the fly' through a call to standard function NEW. A raise statement that omits the exception object argument will re-raise the current exception. This form of a raise statement is allowed only in an exception block.

Control never returns from a raise statement. Rather, control is passed to the innermost exception handler that can handle exceptions of a given class. Innermost in this case means the handler whose try-except block was most recently entered and not yet exited.


Contents | Prev | Next | Index

Canterbury Pascal for JVM  (Last documentation update Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com  . All rights reserved.
Please send any comments or corrections to neuhoff@mhccorp.com