<i>GOO</i> Manual -- Conditions

|  |  | Conditions

# Conditions

Conditions are objects representing exceptional situations. GOO provides restartable conditions as well as the more traditional stack unwinding conditions. A condition is an object used to provide information to a handler. A handler is an object with a handler function used to take care of conditions of a particular type. Signalling is a mechanism for finding the most appropriate handler for a given condition. See DRM [4] for more information.

`<condition>` | `(<any>)` | `C`
`default-handler` | `(x|<condition> => <fun>)` | `G`
| called if no appropriate handler is in force. |
`default-handler-description` | `(c|<condition> => <str>)` | `G`
| return a string describing an anonymous handler for this type of condition. |
`build-condition-interactively` | `(type|<condition> in out => <condition>)` | `G`
| construct a condition of the specified type and interactively prompt the user to fill in any important props. Called by the debugger. Methods should call next-method to build the condition, then set the props for their own class. |
`sig` | `(x|<condition> args|...)` | `G`
| signals a condition with optional arguments args. |
`<simple-condition>` | `(<condition>)` | `C`
| a condition consisting of a `msg` message and arguments. |
`condition-message` | `(x|<simple-condition> => <str>)` | `P`
| returns `msg` string. |
`condition-arguments` | `(x|<simple-condition> => <lst>)` | `P`
| returns `msg` string arguments. |
`<serious-condition>` | `(<condition>)` | `C`
| a condition that can not be safely ignored. |
`<error>` | `(<serious-condition>)` | `C`
| a condition that indicates something is invalid about the program. |
`error` | `(x|<any> args|...)` | `G`
| signals an error. |
`error` | `(x|<str> args|...)` | `M`
| signals a simple error. |
`<simple-error>` | `(<error> <simple-condition>)` | `C`
| an error that consists of a `msg` message and arguments. |
`<restart>` | `(<condition>)` | `C`
| used for restarting a computation. |
`<handler>` | `(<any>)` | `C`
| object used for handling a signaled condition. |
`handler-function` | `(x|<handler> => <fun>)` | `G`
`fab-handler` | `(x|<fun> => <handler>)` | `G`
| creates a handler from a handler function. |
`handler-matches?` | `(x|<handler> y|<condition> => <log>)` | `G`
| protocol for determining whether a handler handles a particular condition. |
`TRY` | `(TRY ,try-options ,handler ,@body)` | `S`
| installs `,handler` as a condition handler for the duration of `(SEQ ,@body)`, using the instructions provided by `,try-options`. `,try-options` should either be the name of the condition type to `handle`, or a `,try-option-list` with zero or more of the following options: `(TYPE ,expr) =>` An expression returning the type of condition to handle. `(TEST ,@body) => Code` which returns `#t` if the condition is applicable, and `#f` otherwise. This may be called at arbitrary times by the runtime, so it shouldn't do anything too alarming. `(DESCRIPTION ,message ,@arguments) =>` A human-readable description of this handler. Used by the debugger. The handler function should take two arguments: the `,condition` to be handled, and a `,resume` function. if a matching condition is signaled then the handler function is called with the signaled condition and a resume function to be called if the handler wants to return a value to be used as the result of the signaling `SIG` call. the handler has three possibilities: (1) it can handle the condition by taking an exit using `ESC`, (2) it can resume to the original `SIG` call using the resume function called with the value to be returned, or (3) it can do neither, that is, it can choose not to handle the condition by just falling through to the end of the handler (cf., Dylan's `BLOCK`/`EXCEPTION` and `LET HANDLER`) and the next available handler will be invoked. Note that GOO does not unwind the stack before calling handlers! |

where

`handler` | `== (fun (,condition ,resume) ,@body)` | `L`
`,try-options` | `== ,condition-type-name | ,try-option-list` | `L`
`,try-option-list` | `== (,try-option* )` | `L`
`,try-option` | `== (,option-name ,@option-value)` | `L`

- Conditions Hierarchy

|  |  | Conditions