Creating new exceptions
Exceptions are instances of the class ExceptionalEvent and are created by sending the message newChild to an existing, or "parent," exception. The most general exception is an instance of ExceptionalEvent called ExAll, which has no parent. All other exceptions are "children" of exactly one other (more general) exception. This creates a hierarchy of exceptions. Instances of ExceptionalEvent maintain the following state:
description
A String that describes the general circumstances where the exception arises (the "error message").
parent
The exception's parent, nil for ExAll.
resumable
A Boolean that is true if running can be resumed at the place where the exception was signaled. It is copied from parent to child on creation, and is false for ExAll.
defaultHandler
A one-argument block that is fired if the exception is not explicitly handled. The default handler block is passed the instance of Signal that describes the exception that was signaled. If nil, the parent's defaultHandler is applied. The defaultHandler in ExAll sends error:.
The following examples create a couple of types of exception:
Example: creating an end of file exception
| anEndOfFileException |
(anEndOfFileException := ExAll newChild)
description: 'end of file'.
Example: creating a message not understood exception
| aMessageNotUnderstoodException |
(aMessageNotUnderstoodException := ExAll newChild)
description: 'message not understood'.
Last modified date: 01/29/2015