Singularity : exception;
To be complete, here's the syntax for defining an exception, describing using BNF:
exception_declaration ::= defining_identifier_list ": exception;" defining_identifier_list ::= identifier { "," identifier }
Exception declarations are generally placed in a package declaration.
Raising an exception is easy, too - just use the raise statement. A raise statement is simply the keyword "raise" followed by the name of the exception; the syntax in BNF is:
raise_statement ::= "raise" [ exception_name ] ";"
You'll notice that the exception_name is optional; we'll discuss what that means in the next section.
There is no quiz question for this section.
You may go to the next section.
Go back to the previous section
Go up to the outline of lesson 10
David A. Wheeler (wheeler@ida.org)