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:
parent
cceac91b8b
commit
7cb1d4d305
6 changed files with 111 additions and 21 deletions
|
@ -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.
|
||||||
|
|
|
@ -669,25 +669,56 @@
|
||||||
|
|
||||||
|
|
||||||
;; 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))
|
||||||
(msghead (cond
|
(rest (cadddr arg-list))
|
||||||
(b (caddr b))
|
(cep (current-error-port))
|
||||||
((or (symbol? desc) (string? desc))
|
(fill-message (lambda (message args)
|
||||||
(string-append desc " "))
|
(let ((len (string-length message)))
|
||||||
(#t "Unknown error")))
|
(cond ((< len 2)
|
||||||
(msg (if (symbol? proc)
|
(display message cep))
|
||||||
(string-append msghead proc ":")
|
((string=? (substring message 0 2)
|
||||||
msghead))
|
"%S")
|
||||||
(rest (if (and proc (not (symbol? proc)))
|
(display (car args) cep)
|
||||||
(cons proc args)
|
(fill-message
|
||||||
args))
|
(substring message 2 len)
|
||||||
(fixed-args (cons msg rest)))
|
(cdr args)))
|
||||||
(apply error fixed-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
|
||||||
|
(b (caddr b))
|
||||||
|
((or (symbol? desc) (string? desc))
|
||||||
|
(string-append desc " "))
|
||||||
|
(#t "Unknown error")))
|
||||||
|
(msg (if (symbol? proc)
|
||||||
|
(string-append msghead proc ":")
|
||||||
|
msghead))
|
||||||
|
(rest (if (and proc (not (symbol? proc)))
|
||||||
|
(cons proc args)
|
||||||
|
args))
|
||||||
|
(fixed-args (cons msg rest)))
|
||||||
|
(apply error fixed-args)))))
|
||||||
|
|
||||||
|
|
||||||
(set-symbol-property! '%%system-error
|
(set-symbol-property! '%%system-error
|
||||||
|
|
|
@ -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).
|
||||||
|
|
||||||
|
|
|
@ -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) \
|
#define SCM_SYSERROR(_subr) \
|
||||||
scm_everr (SCM_UNDEFINED, SCM_EOL, SCM_UNDEFINED, \
|
lgh_error (system_error_sym, \
|
||||||
strerror (errno), _subr)
|
_subr, \
|
||||||
|
"%S", \
|
||||||
|
scm_listify (scm_makfrom0str (strerror (errno)), \
|
||||||
|
SCM_UNDEFINED), \
|
||||||
|
scm_listify (SCM_MAKINUM (errno), SCM_UNDEFINED));
|
||||||
|
|
||||||
|
/*
|
||||||
|
old version:
|
||||||
|
#define SCM_SYSERROR(_subr) \
|
||||||
|
scm_everr (SCM_UNDEFINED, SCM_EOL, SCM_UNDEFINED, \
|
||||||
|
strerror (errno), _subr)
|
||||||
|
*/
|
||||||
|
|
||||||
/* equivalent to:
|
/* equivalent to:
|
||||||
scm_throw (system_error_sym, \
|
scm_throw (system_error_sym, \
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue