From 563b6367a572bc50f8fbec2aeff255c258407862 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 21 Feb 2015 06:07:57 -0800 Subject: Improved error reporting, particularly for macro expansion. * eval.c (last_form_expanded): New variable. (do_expand): New static function; contains previous expand function. (expand): Becomes a wrapper for do_expand, with re-entry counting. (eval_init): GC-protect last_form_expanded. * eval.h (last_form_expanded): Declared. * parser.l (regex_parse, lisp_parse): Just use a simple word for the name of the regex or string parse location, not the entire expression itself. * unwind.c (uw_throw): Check whether expansion was going on when the unhandled exception was thrown and print additional information. --- unwind.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'unwind.c') diff --git a/unwind.c b/unwind.c index 5d358e42..51c2dae0 100644 --- a/unwind.c +++ b/unwind.c @@ -315,12 +315,18 @@ val uw_throw(val sym, val args) val msg_or_args = if3(is_msg, car(args), args); val info = if2(source_loc(last_form_evaled), source_loc_str(last_form_evaled)); + val ex_info = if2(source_loc(last_form_expanded), + source_loc_str(last_form_expanded)); format(std_error, lit("~a: unhandled exception of type ~a:\n"), prog_string, sym, nao); if (info && sym != eval_error_s) - format(std_error, lit("~a: possibly triggered by ~a\n"), - prog_string, info, nao); + format(std_error, lit("~a: possibly triggered at ~a by form ~s\n"), + prog_string, info, last_form_evaled, nao); + + if (ex_info) + format(std_error, lit("~a: during expansion at ~a of form ~s\n"), + prog_string, ex_info, last_form_expanded, nao); format(std_error, if3(is_msg, -- cgit v1.2.3