Chapter 12
The Built-In Functions
The following functions are used to create, signal, handle, and examine conditions.
signal [Function]
signal condition
⇒ #rest values
signal string #rest arguments
⇒ #rest values
An instance of <condition>.
An instance of <string>.
Instances of <object>.
Instances of <object>.
Signals the condition, trying each active dynamic handler, the most recent first. If all dynamic handlers decline, signal calls default-handler(condition). If a handler returns, all the values that it returned are returned from signal. If signal returns when condition's recovery protocol does not allow returning, some handler has violated protocol; signal does not check for this error. If condition is a restart, the caller of signal should always assume that it might return.
The second form signals a condition of type <simple-warning>.
error [Function]Signals a nonrecoverable error.
error condition
⇒ {will never return}
error string #rest arguments
⇒ {will never return}
An instance of <condition>.
An instance of <string>.
Instances of <object>.
None. error will never return.
error is similar to signal but never returns; if a handler returns, error invokes the debugger immediately. error is used to make it clear that a program does not expect to receive control again after signaling a condition and might enable the compiler to generate slightly more compact code.
The second form signals a condition of type <simple-error>.
cerror [Function]
cerror restart-description condition
⇒ false
cerror restart-description string #rest arguments
⇒ false
An instance of <string>, interpreted as a format string.
An instance of <condition>.
An instance of <string>, interpreted as a format string.
An instance of <string>.
Instances of <object>.
#f.
cerror is the same as error but first establishes a handler for <simple-restart>, with a format string of restart-description and format arguments of a sequence containing the arguments.
If the restart handler is invoked, cerror returns #f; otherwise, cerror never returns. If cerror returns, the program should take the corrective actions promised in the restart-description. cerror is the standard way to signal correctable errors when no special class of restart condition is required.
break [Function]
break condition
⇒ false
break string #rest arguments
⇒ false
break
⇒
An instance of <condition>.
An instance of <string>, interpreted as a format string.
Instances of <object>, interpreted as format arguments.
None.
#f.
Obtains a condition in the same way as signal but then invokes the debugger immediately without signaling first. break establishes a <simple-restart> so the debugger can continue execution. This is useful for breakpoints. break always returns #f. With no arguments, a default message string is used.
The behavior of the debugger is implementation-defined.
check-type [Function]Checks an object to ensure that it is an instance of a specified type.
check-type value type
⇒ value
An instance of <object>.
An instance of <type>.
An instance of <object>.
Checks value to ensure that it is an instance of type, and signal an error of type <type-error> if it is not.
abort [Function]Aborts and never returns.
abort
None.
None. abort will never return.
Performs error(make (<abort>)).
This function is provided as a convenient shortcut. The call is to error, rather than to signal, to guarantee that abort will never return.
default-handler [Open Generic Function]Called if no dynamic handler handles a condition.
default-handler condition
⇒ #rest values
An instance of <condition>.
Instances of <object>.
Called if no dynamic handler handles a condition.
default-handler condition ⇒ false [G.F. Method]A predefined method on <condition> simply returns #f.
default-handler serious-condition ⇒ {does not return} [G.F. Method]A predefined method on <serious-condition> invokes an implementation-defined debugger.
default-handler warning ⇒ false [G.F. Method]A predefined method on <warning> prints the warning's message in an implementation-defined way and then returns #f.
default-handler restart ⇒ {does not return} [Sealed G.F. Method]A predefined method on <restart> signals an error.
restart-query [Open Generic Function]Called to query the user and restart.
restart-query restart
⇒ #rest values
An instance of <restart>.
Instances of <object>.
Engages the interactive user in a dialog and stores the results in slots of restart.
This function is designed to be called from a handler, after making a restart and before signaling it. The debugger uses restart-query, for example.
restart-query restart ⇒ object [G.F. Method]There is a default method for <restart> that does nothing.
return-query [Open Generic Function]Queries the user for values to return.
return-query condition
⇒ #rest values
An instance of <condition>.
Instances of <object>.
If the recovery protocol of condition allows returning values, this engages the program user in a dialog and returns the results as any number of values, which the handler should return.
return-query should not be called if return-allowed? returns #f. Programs that define condition classes whose recovery protocol allows returning values should ensure that there is an appropriate method for this function defined on or inherited by the condition class.
do-handlers [Function]Applies a function to all dynamically active handlers.
do-handlers function
⇒ false
An instance of <function>.
#f.
Applies function to all dynamically active handlers, the most recently established first. function receives four arguments: type, test, function, and init-arguments. The arguments describe a dynamically active handler. All arguments have dynamic extent and must not be modified. test defaults to a function that always returns #t. init-arguments will be an empty sequence if it was not supplied by the handler.
return-allowed? [Open Generic Function]Returns true if a condition's recovery protocol allows returning values.
return-allowed? condition
⇒ boolean
An instance of <condition>.
An instance of <boolean>.
Returns #t if the recovery protocol of condition allows returning values, or #f if it does not.
There is a default method for <condition> that returns #f. Programs which define condition classes whose recovery protocol allows returning values should ensure that there is an appropriate method for this function defined on or inherited by the condition class.
return-allowed? condition ⇒ false [G.F. Method]There is a default method for <condition> that returns #f.
return-description [Open Generic Function]Returns a description of a condition's returned values.
return-description condition
⇒ description
An instance of <condition>.
#f or an instance of <string> or an instance of <restart>.
If the recovery protocol of this condition allows returning values, return-description returns a description of the meaning of returning values.
This description can be a restart, a string, or #f. return-description should not be called if return-allowed? returns #f. If you define your own condition class whose recovery protocol allows returning values, you need to define a method for return-description unless the inherited method is suitable.
condition-format-string [Function]Returns the format string of a simple condition.
condition-format-string simple-condition
⇒ format-string
An instance of <simple-error>, <simple-warning>, or <simple-restart>.
An instance of <string>.
Returns the format string that was supplied as an initialization argument when the simple-condition was created.
condition-format-arguments [Function]Returns the format arguments of a simple condition.
condition-format-arguments simple-condition
⇒ format-args
An instance of <simple-error>, <simple-warning>, or <simple-restart>.
An instance of <sequence>.
Returns the sequence of format arguments that was supplied as an initialization argument when the simple-condition was created.
type-error-value [Function]Returns the value that was not of the expected type.
type-error-value type-error
⇒ object
An instance of <type-error>.
An instance of <object>.
Returns the value that was not of the expected type, and thereby led to the type error.
type-error-expected-type [Function]Returns the expected type of the type check that led to the type error.
type-error-expected-type type-error
⇒ type
An instance of <type-error>.
An instance of <type>.
Returns the expected type of the type check that led to the type error.