System exceptions
Globally accessible exceptions are stored in the pool dictionary named SystemExceptions. By convention, the names of the exceptions in this pool begin with 'Ex.' SystemExceptions is a pool dictionary belonging to Object and is therefore accessible by all subclasses of Object.
The following table lists system exceptions in the SystemExceptions pool dictionary.
Table 5. SystemExceptions pool dictionary
Pool variable name
The most general exception.
The exception signaled by Object>>error:. This exception is signaled with the string passed to error:.
The exception signaled by Object>>halt. This exception is signaled with the string passed to halt:. Note that Object>>halt sends halt:.
The exception signaled by the system default break handler.
The system exceptions ExError, ExHalt, and ExUserBreak use the first argument for the error string when opening a debugger. If you create a child of these exceptions, you must follow the same convention. Alternatively, you can provide a defaultHandler in the child, which sends error: with an appropriate error message. The defaultHandler for the system exceptions uses the description of the exception as the error string if the first argument is not a string. If you are using exceptions to return non-string values in the arguments of the signal (a reasonable use) then you should provide a default handler for your exceptions that knows that the arguments will not be strings. For example:
| anErrorException |
(anErrorException := ExError newChild)
description: 'a demonstration error occurred';
defaultHandler: [:sig |
self error: 'My error occurred with arguments: ',
sig arguments printString].
anErrorException signalWith: 1 with: 2.
Last modified date: 05/12/2020