Status: mostly complete, though probably not robust.
Description: no matter who you are, from the lowliest scheme
newbie, to the froodiest master programmer, eventually you'll try to
take the car of 1 ... `error.c' deals with reporting
such brain farts.
Guile's exception mechanism revolves around catch/throw,
which is simple, but still flexible. This allows you to handle a certain
error in your own way, by doing a
(catch 'error-tag
(lambda () (dostuff))
(lambda (key . args) (reportstuff)))
Which prevents the builtin error handler from being called. You can also do a
(catch #t ...) to catch all errors.
Note: I think the order of intent was, in fact, to implement
errors, which was followed by the realization that
catch/throw could be generally useful. It doesn't really
matter either way.
Note: for each type of builtin error, the first function
specific to the error will include a (key: "foo") entry, which
gives the actual tag that's thrown for the error.
Note: this doesn't detail the actual system handlers, since these aren't actually implemented in `error.c'.
Defined Error Keys:
system-error
numerical-overflow
out-of-range
wrong-number-of-args
wrong-type-arg
memory-allocation-error
misc-error
scm_ithrow(key, arg-list, 1). If the
subr or message arguments are NULL, their values in
the list are #f.
scm_error. It treats
#f arguments for subr and message args the same way
scm_error treats NULL.
"system-error"). subr is the function that caused all the ruckas.
The strerror is displayed.
scm_syserror, but allows you to specify exactly what you
want shown.
"numerical-overflow").
"out-of-range"). The message
consists of "Argument out of range: [bad_value]" (at least in theory,
there's screwage that can happen with certain types of args).
"wrong-number-of-args"). The
proc argument is the procedure where the trouble happened, and is
displayed as part of the message.
"wrong-type-arg") to subroutine
subr, at pos in it's argument list. bad_val is the
argument that caused all the commotion.
"memory-allocation-error") in
subr.
"misc-error").
SCM_ASSERT macro. arg is the offending argument.
pos is either SCM_ARG[n1-7] (all signal a wrong-type-arg in
pos 1-7, or 0 (for n? dunno why that is), SCM_WNA (signal
wrong number of args), SCM_OUTOFRANGE (out of range error),
SCM_NALLOC (a memory error), or a string, in which case
scm_misc_error is called, with s_subr and pos.
As per usual, s_subr is the subroutine where all the fun took place.