A computer-language implementation designer faces choices of how reflexive to make the implementation in handling exceptions and errors; that is, how much of the error and exception routines should be written in the language itself. The design of a portable implementation is further constrained by the need to have (almost) all errors print meaningful messages, even when the implementation itself is not functioning correctly. Therefore, SCM implements much of its error response code in C.
The following common error and conditions are handled by C code. Those with callback names after them can also be handled by Scheme code (see Interrupts). If the callback identifier is not defined at top level, the default error handler (C code) is invoked. There are many other error messages which are not treated specially.
When SCM encounters a non-fatal error, it aborts evaluation of the current form, prints a message explaining the error, and resumes the top level read-eval-print loop. The value of errobj is the offending object if appropriate. The builtin procedure
errordoes not set errobj.
perror report ANSI C errors encountered during a
call to a system or library function.
With no argument returns the current value of the system variable
errno. When given an argument,
errnosets the system variable
errnoto n and returns the previous value of
(errno 0)will clear outstanding errors. This is recommended after
#fsince this occurs when the file could not be opened.
Prints on standard error output the argument string, a colon, followed by a space, the error message corresponding to the current value of
errnoand a newline. The value returned is unspecified.
error provide a uniform way for Scheme code to
signal warnings and errors.
Alias for slib:warn. Outputs an error message containing the arguments.
warnis defined in Init5e7.scm.
Alias for slib:error. Outputs an error message containing the arguments, aborts evaluation of the current form and resumes the top level read-eval-print loop.
Erroris defined in Init5e7.scm.
If SCM is built with the ‘CAUTIOUS’ flag, then when an error occurs, a stack trace of certain pending calls are printed as part of the default error response. A (memoized) expression and newline are printed for each partially evaluated combination whose procedure is not builtin. See Memoized Expressions for how to read memoized expressions.
Also as the result of the ‘CAUTIOUS’ flag, both
user-interrupt (invoked by <C-c>) are defined to print stack
traces and conclude by calling
(see Breakpoints). This allows the user to
interract with SCM as with Lisp systems.