Properly handle rt errors

This commit is contained in:
Justin Ethier 2015-04-16 22:39:04 -04:00
parent 13c9d44500
commit 060d256f4a
2 changed files with 17 additions and 27 deletions

View file

@ -15,11 +15,13 @@
(with-exception-handler
(lambda (obj)
(display "Error: ")
(for-each
(lambda (o)
(display o)
(display " "))
obj)
(display obj)
; TODO: if list, do this instead:
;(for-each
; (lambda (o)
; (display o)
; (display " "))
; obj)
(display "\n")
(k #t))
(lambda ()

View file

@ -1258,37 +1258,25 @@ object Cyc_current_exception_handler() {
/* Raise an exception from the runtime code */
void Cyc_rt_raise(object err) {
//printf("DEBUG err = ");
//Cyc_display(err);
//printf("\n");
make_cons(c2, err, nil);
make_cons(c1, boolean_f, &c2);
apply(nil, Cyc_current_exception_handler(), &c1);
make_cons(c0, &c1, nil);
//printf("sending to apply => ");
//Cyc_display(&c0);
//printf("\n");
apply(nil, Cyc_current_exception_handler(), &c0);
// Should never get here
fprintf(stderr, "Internal error in Cyc_rt_raise\n");
exit(1);
}
void Cyc_rt_raise_msg(const char *err) {
printf("TODO: %s", err);
exit(1);
//make_string(s, err);
//Cyc_rt_raise(&s);
make_string(s, err);
Cyc_rt_raise(&s);
}
/* Provide the ability to raise an exception from the C runtime.
Other runtime functions should call this as needed
TODO: consolidate this with (raise) in trans.scm ????
* /
TODO:
object Cyc_raise(object err) {
// TODO: probably best to re-arrange things to not rely on a global here
object ehs = (object) __glo__85exception_91handler_91stack_85;
if (boolean_f == ehs) {
Cyc_default_exception_handler(1, (closure)err, err);
} else {
// TODO: call into just like (raise) car(ehs)
}
return nil;
} */
/* END exception handler */
/*