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.
Wrong type in argument
Wrong type in argument 1
Wrong type in argument 2
Wrong type in argument 3
Wrong type in argument 4
Wrong type in argument 5
Wrong number of args
Argument out of range
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
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,
errno sets the system
errno to n and returns the previous value of
(errno 0) will clear outstanding errors. This is
#f since 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
errno and a newline. The value returned is unspecified.
error provide a uniform way for Scheme code to
signal warnings and errors.
Alias for slib:warn in SLIB. Outputs an error
message containing the arguments.
warn is defined in
Alias for slib:error in SLIB. Outputs an error
message containing the arguments, aborts evaluation of the current form
and resumes the top level read-eval-print loop.
Error is defined
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 in SLIB). This allows the user to
interract with SCM as with Lisp systems.
Prints information describing the stack of partially evaluated
#t if any lines were
#f otherwise. See Init5f3.scm
for an example of the use of