[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


error

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

C Function: void scm_error (SCM key, char *subr, char *message, SCM args, SCM rest)
This is where all errors go to get thrown. Basically, it just makes a list from the subr, message, args and rest arguments, then does a scm_ithrow(key, arg-list, 1). If the subr or message arguments are NULL, their values in the list are #f.

Function: scm-error key subr message args rest
C Function: SCM scm_error_scm (SCM key, SCM subr, SCM message, SCM args, SCM rest)
This is a scheme level interface to scm_error. It treats #f arguments for subr and message args the same way scm_error treats NULL.

Function: strerror err
C Function: SCM scm_strerror (SCM err)
This performs the exact same purpose as the c function of the same name. err is a system errno, and this returns a string describing it.

C Function: void scm_syserror (char *subr)
This is the function called when a syserror occurs (key: "system-error"). subr is the function that caused all the ruckas. The strerror is displayed.

Function: void scm_syserror_msg (char *subr, char *message, SCM args, int errno)
Like scm_syserror, but allows you to specify exactly what you want shown.

C Function: void scm_sysmissing (char *subr)
Error on a missing function.

C Function: void scm_num_overflow (char *subf)
Signals a numerical overflow error (key: "numerical-overflow").

C Function: void scm_out_of_range (char *sub, SCM bad_value)
Signals an out of range error (key: "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).

C Function: void scm_wrong_num_args (SCM proc)
Signals a wrong number of args error (key: "wrong-number-of-args"). The proc argument is the procedure where the trouble happened, and is displayed as part of the message.

C Function: void scm_wrong_type_arg (SCM subr, int pos, SCM bad_val)
Signals a wrong type arg (key: "wrong-type-arg") to subroutine subr, at pos in it's argument list. bad_val is the argument that caused all the commotion.

C Function: void scm_memory_error (char *subr)
Signals a memory allocation error (key: "memory-allocation-error") in subr.

C Function: void scm_misc_error (char *subr, char *message, SCM args)
Signals an error for which no special tag is defined (key: "misc-error").

C Function: SCM scm_wta (SCM arg, char *pos, char *s_subr)
This is the `wrong type argument' function, which forms the core of the 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.


[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]