Next: , Previous: Handling exceptions, Up: Exception handling

6.11.4 When an exception isn't handled

Every exception chooses one of the above handler actions by default when no handler is found, or they all use #pass. This is invoked by sending #defaultAction to the class.

One example of a default action is presented above as part of the example of #error: usage; that default action prints a message, backtrace, and unwinds the stack all the way.

The easiest way to choose a default action for your own exception classes is to subclass from an exception class that already chose the right one, as explained in the next section. For example, some exceptions, such as warnings, resume by default, and thus should be treated as if they will almost always resume.

Selecting by superclass is by no means a requirement. Specializing your Error subclass to be resumable, or even to resume by default, is perfectly acceptable when it makes sense for your design.