Error handling is based on
throw. Errors are
always thrown with a key and four arguments:
~Scan be embedded within the message: they will be replaced with members of the args list when the message is printed.
~Aindicates an argument printed using
~Sindicates an argument printed using
write. message can also be
#f, to allow it to be derived from the key by the error handler (may be useful if the key is to be thrown from both C and Scheme).
~Stokens in message. Can also be
#fif no arguments are required.
'system-error, this contains the C errno value. Can also be
#fif no additional objects are required.
In addition to
throw, the following Scheme
facilities are available:
Display an error message to the output port port. stack is the saved stack for the error, subr is the name of the procedure in which the error occurred and message is the actual error message, which may contain formatting instructions. These will format the arguments in the list args accordingly. rest is currently ignored.
The following are the error keys defined by libguile and the situations in which they are used:
error-signal: thrown after receiving an unhandled fatal signal such as SIGSEGV, SIGBUS, SIGFPE etc. The rest argument in the throw contains the coded signal number (at present this is not the same as the usual Unix signal number).
system-error: thrown after the operating system indicates an error condition. The rest argument in the throw contains the errno value.
numerical-overflow: numerical overflow.
out-of-range: the arguments to a procedure do not fall within the accepted domain.
wrong-type-arg: an argument to a procedure has the wrong type.
wrong-number-of-args: a procedure was called with the wrong number of arguments.
memory-allocation-error: memory allocation error.
stack-overflow: stack overflow error.
regular-expression-syntax: errors generated by the regular expression library.
misc-error: other errors.
In the following C functions, SUBR and MESSAGE parameters
NULL to give the effect of
#f described above.
Throw an error, as per
scm-error(see Error Reporting).
Throw an error with key
errnoin the rest argument. For
scm_syserrorthe message is generated using
Care should be taken that any code in between the failing operation and the call to these routines doesn't change
Throw an error with the various keys described above.
scm_wrong_num_args, proc should be a Scheme symbol which is the name of the procedure incorrectly invoked.