From a18f1923f6220919027cfc6c1fb656326affd001 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 12 Jun 2015 21:15:07 -0400 Subject: [PATCH] Fixed consistency issues with default ex handler Previously there was a difference between how the default handler displayed objects compared to custom exception handlers. This has been fixed up so all error objects are displayed consistently. --- runtime.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/runtime.c b/runtime.c index 54669541..a473cbba 100644 --- a/runtime.c +++ b/runtime.c @@ -166,11 +166,20 @@ object Cyc_glo_eval = nil; object Cyc_exception_handler_stack = nil; object Cyc_default_exception_handler(int argc, closure _, object err) { - printf("Error: "); - // TODO: error should be a list of form (type arg1 ... argn) - // want to ignore type and display args without enclosing parens - Cyc_display_va(1, err); - printf("\n"); + fprintf(stderr, "Error: "); + + if (nullp(err) || is_value_type(err) || type_of(err) != cons_tag) { + Cyc_display(err, stderr); + } else { + // Error is list of form (type arg1 ... argn) + err = cdr(err); // skip type field + for (; !nullp(err); err = cdr(err)){ // output with no enclosing parens + Cyc_display(car(err), stderr); + fprintf(stderr, " "); + } + } + + fprintf(stderr, "\n"); exit(1); return nil; }