Programmer's Reference

Signaling an exception

Exceptions are signaled by sending one of the following methods to the appropriate instance of ExceptionalEvent:

signal
Invokes the exception with no arguments.
signalWith:
Invokes the exception with a single argument.
signalWith:with:
Invokes the exception with two arguments.
signalWithArguments:
Invokes the exception with anArray of arguments

The following examples signal a couple of types of exception:

Example: signaling end of file

| anEndOfFileException |
(anEndOfFileException := ExAll newChild)
    description: 'end of file'.
anEndOfFileException signal.

Example: signaling message not understood

| aMessageNotUnderstoodException |
(aMessageNotUnderstoodException := ExAll newChild)
    description: 'message not understood'.
aMessageNotUnderstoodException
    signalWith: (DirectedMessage selector: #halt arguments: #() receiver: self)

When an exception is signaled, an instance of class Signal is created that contains information describing the circumstances where the exception occurred.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]