<< Prev | - Up - | Next >> |
The module Exception
provides procedures to construct exceptions and raise them.
Special Exceptions
Any value may be raised as exception, although commonly only records are used. Some of these serve special purposes: error exceptions are records with label error
. These are raised when a programming error occurs; it is not recommended to catch these. System exceptions are records with label system
. These are raised when an unforeseeable runtime condition occurs; a file operations library might raise system exceptions when a file cannot be opened. It is recommended to always handle such exceptions. Failure exceptions are records with label failure
; these are raised when a tell operation fails.
Dispatch Fields
Both error and system exceptions have a dispatch field. This is the subtree at feature 1
of the exception record. This is usually a record further describing the exact condition that occurred.
Debug Information
If an exception is a record and has a feature debug
with value unit
, then the implementation may replace (depending on the value of the property ozconf.errorDebug
) the corresponding subtree by implementation-dependent debugging information. This is to be printed out in the case of uncaught exceptions.
All procedures in the Base Environment only ever raise special-purpose exceptions as described above.
error
{Exception.error
X
?Y
}
returns an error exception record with dispatch field X
.
system
{Exception.system
X
?Y
}
returns a system exception record with dispatch field X
.
failure
{Exception.failure
X
?Y
}
returns a failure exception. The value X
may give a hint on why failure occurred; implementations may store this inside the constructed exception's debug
field.
Raise
{Exception.'raise'
X
}
raises X
as an exception.
raiseError
{Exception.raiseError
X
}
wraps X
into an error exception and raises this. This procedure can be defined as follows, except that it always add debug informations:
proc {Exception.raiseError X}
{Exception.'raise' {AdjoinAt {Exception.error X} debug unit}}
end
<< Prev | - Up - | Next >> |