1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 17:20:29 +02:00

* error.c (scm_error): declare scm_error_callback.

* error.h: prototype for scm_error_callback.

	* __scm.h: define lgh_error.
 	(SCM_SYSERROR): redefine using lgh_error.

	* boot-9.scm (%%handle-system-error): recognise errors thrown
	by lgh-error (fill-message etc.)
This commit is contained in:
Gary Houston 1996-09-07 20:48:45 +00:00
parent cceac91b8b
commit 7cb1d4d305
6 changed files with 111 additions and 21 deletions

View file

@ -1,3 +1,8 @@
Sat Sep 7 06:44:47 1996 Gary Houston <ghouston@actrix.gen.nz>
* boot-9.scm (%%handle-system-error): recognise errors thrown
by lgh-error (fill-message etc.)
Thu Sep 5 11:33:41 1996 Jim Blandy <jimb@floss.cyclic.com> Thu Sep 5 11:33:41 1996 Jim Blandy <jimb@floss.cyclic.com>
* boot-9.scm: %load-path is initialized in C code now. * boot-9.scm: %load-path is initialized in C code now.

View file

@ -669,12 +669,43 @@
;; The default handler for built-in error types when ;; The default handler for built-in error types when
;; thrown by their symbolic name. The action is to ;; thrown by their symbolic name.
;; convert the error into a generic error, building (define (%%handle-system-error key . arg-list)
;; a descriptive message for the error. (cond ((= (length arg-list) 4)
;; (letrec ((subr (car arg-list))
(define (%%handle-system-error ignored desc proc . args) (message (cadr arg-list))
(let* ((b (assoc desc %%system-errors)) (args (caddr arg-list))
(rest (cadddr arg-list))
(cep (current-error-port))
(fill-message (lambda (message args)
(let ((len (string-length message)))
(cond ((< len 2)
(display message cep))
((string=? (substring message 0 2)
"%S")
(display (car args) cep)
(fill-message
(substring message 2 len)
(cdr args)))
(else
(display (substring message 0 2)
cep)
(fill-message
(substring message 2 len)
args)))))))
(display "ERROR: " cep)
(display subr cep)
(display ": " cep)
(fill-message message args)
(newline cep)
(force-output cep)
(apply throw 'abort key arg-list)))
(else
;; old style errors.
(let* ((desc (car arg-list))
(proc (cadr arg-list))
(args (cddr arg-list))
(b (assoc desc %%system-errors))
(msghead (cond (msghead (cond
(b (caddr b)) (b (caddr b))
((or (symbol? desc) (string? desc)) ((or (symbol? desc) (string? desc))
@ -687,7 +718,7 @@
(cons proc args) (cons proc args)
args)) args))
(fixed-args (cons msg rest))) (fixed-args (cons msg rest)))
(apply error fixed-args))) (apply error fixed-args)))))
(set-symbol-property! '%%system-error (set-symbol-property! '%%system-error

View file

@ -1,5 +1,18 @@
Sat Sep 7 06:57:23 1996 Gary Houston <ghouston@actrix.gen.nz>
* error.c (scm_error): declare scm_error_callback.
* error.h: prototype for scm_error_callback.
* __scm.h: define lgh_error.
(SCM_SYSERROR): redefine using lgh_error.
Thu Sep 5 22:40:06 1996 Gary Houston <ghouston@actrix.gen.nz> Thu Sep 5 22:40:06 1996 Gary Houston <ghouston@actrix.gen.nz>
* error.c (scm_error): new procedure.
* error.h: prototype for scm_error.
* Makefile.in (install): install scmconfig.h from the current * Makefile.in (install): install scmconfig.h from the current
directory, not $(srcdir). directory, not $(srcdir).

View file

@ -296,9 +296,23 @@ extern unsigned int scm_async_clock;
goto _label goto _label
#endif #endif
#define lgh_error(_key, _subr, _message, _args, _rest) \
scm_error (_key, _subr, _message, _args, _rest)
#define SCM_SYSERROR(_subr) \
lgh_error (system_error_sym, \
_subr, \
"%S", \
scm_listify (scm_makfrom0str (strerror (errno)), \
SCM_UNDEFINED), \
scm_listify (SCM_MAKINUM (errno), SCM_UNDEFINED));
/*
old version:
#define SCM_SYSERROR(_subr) \ #define SCM_SYSERROR(_subr) \
scm_everr (SCM_UNDEFINED, SCM_EOL, SCM_UNDEFINED, \ scm_everr (SCM_UNDEFINED, SCM_EOL, SCM_UNDEFINED, \
strerror (errno), _subr) strerror (errno), _subr)
*/
/* equivalent to: /* equivalent to:
scm_throw (system_error_sym, \ scm_throw (system_error_sym, \

View file

@ -191,7 +191,32 @@ scm_wta (arg, pos, s_subr)
return SCM_UNSPECIFIED; return SCM_UNSPECIFIED;
} }
void (*scm_error_callback) () = 0;
void
scm_error (key, subr, message, args, rest)
SCM key;
char *subr;
char *message;
SCM args;
SCM rest;
{
SCM arg_list;
if (scm_error_callback)
(*scm_error_callback) (key, subr, message, args, rest);
arg_list = scm_listify (scm_makfrom0str (subr),
scm_makfrom0str (message),
args,
rest,
SCM_UNDEFINED);
scm_ithrow (key, arg_list, 1);
/* No return, but just in case: */
write (2, "unhandled system error", sizeof ("unhandled system error") - 1);
exit (1);
}
#ifdef __STDC__ #ifdef __STDC__
void void

View file

@ -53,6 +53,8 @@ extern SCM system_error_sym;
extern void scm_error PROTO ((SCM key, char *subr, char *message, SCM args, SCM rest));
extern void (*scm_error_callback) PROTO ((SCM key, char *subr, char *message, SCM args, SCM rest));
#ifdef __STDC__ #ifdef __STDC__
extern int scm_handle_it (int i); extern int scm_handle_it (int i);