next up previous contents index
Next: 3.13 Concurrency Up: 3 The Slate World Previous: 3.11 Paths   Contents   Index

Subsections

3.12 Exceptional Situations and Errors

Slate has a special kind of object representing when an exceptional situation has been reached in a program, called a Condition. Condition objects may have attributes and methods like other ordinary objects, but have special methods for dealing with exceptional situations and recovering from them in various ways, often automatically.

3.12.1 Types

Condition
An object representing a situation which must be handled. This also provides a hook for working with the control-flow of the situation, and dynamic unwinding of control.
Restart
An object representing and controlling how a condition is handled. Because they are a kind of Condition, they can themselves be handled dynamically.
Warning
A Condition which should generate notifications, but does not need to be raised for handling, i.e. no action needs to be taken. Raised by warn: with a description.
StyleWarning
A Warning that certain conventions set up by the library author have not been followed, which could lead to problems. Raised by note: with a description.
BreakPoint
A Condition that pauses the current computation. Raised by break in a context.
Abort
A Restart which unwinds the stack and cleans up contexts after a condition is raised. This is raised by the context method abort.
SeriousCondition
A Condition that requires handling, but is not a semantic error of the program. Rather, it's due to some incidental or pragmatic consideration.
Error
A SeriousCondition which involves some misstep in program logic, and raises the need for handlers to avoid a program crash. Raised by error: with a description.

3.12.2 Protocol

signal
Raises the exception that is the argument. This will immediately query for exception handlers in the current context, performing dynamic automatic recovery if possible, or starting the debugger if not.
on:do:
Executes the block of code with a dynamically bound handler block for the given type of condition.
ensure:
This is a block method that ensures that the second block is executed either after the first or in any case if the original is aborted or control is otherwise handed elsewhere in the middle of execution without possibility of returning into that same execution.
handlingCases:
Executes the block of code with a set of dynamically bound handler blocks, give as an Array of Associations between Condition objects and the handlers.
return/return:
Returns from the condition with a value (default Nil), to the point where the condition was signalled.
exit/exit:
Aborts from the condition, or aborts from it with a value, to the point where the handler was set up.
defaultHandler
This is the condition method that is called if no other handlers are found for the context.


next up previous contents index
Next: 3.13 Concurrency Up: 3 The Slate World Previous: 3.11 Paths   Contents   Index
Brian Rice 2005-11-21