diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-11-28 18:57:18 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-11-28 18:57:18 -0800 |
commit | 8bd9d47e3c25bfd964bb6950362d169c49887b66 (patch) | |
tree | d8d99533b099f8a0ea5d5a11c33f6bf4638eab99 /unwind.c | |
parent | a67a10b463c0c43d851ec2bb72311130be306128 (diff) | |
download | txr-8bd9d47e3c25bfd964bb6950362d169c49887b66.tar.gz txr-8bd9d47e3c25bfd964bb6950362d169c49887b66.tar.bz2 txr-8bd9d47e3c25bfd964bb6950362d169c49887b66.zip |
Error reports trace through layers of macroexpansion.
* eval.c (error_trace): New function. Consolidates
error reporting between unhandled exception handling
in uw_throw, and the catcher in the repl.
(op_defmacro, expand_macrolet): Propagate location info from
body to wrapping block, and to the macro binding. In the
latter function, also to the body that is wrapped by local
macros.
(do_expand, macroexpand_1): Propagate location info from macro
expander to expansion, only taking it from the form if the
macro doesn't supply it.
* eval.h (error_trace): Declared.
* parser.c (repl): Replace error reporting code with call to
error_trace.
* unwind.c (uw_throw): uw_throw: likewise.
Diffstat (limited to 'unwind.c')
-rw-r--r-- | unwind.c | 30 |
1 files changed, 4 insertions, 26 deletions
@@ -531,34 +531,12 @@ val uw_throw(val sym, val args) } if (opt_loglevel >= 1) { - val is_msg = and2(stringp(car(args)), null(cdr(args))); - val msg_or_args = if3(is_msg, car(args), args); - val info = source_loc_str(last_form_evaled, nil); - val ex_info = source_loc_str(last_form_expanded, nil); - val origin = last_form_evaled; - 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 at ~a by form ~!~s\n"), - prog_string, info, last_form_evaled, nao); - - while ((origin = lookup_origin(origin))) { - val oinfo = source_loc_str(origin, lit("(n/a)")); - format(std_error, lit("~a: which is an expansion at ~a of ~!~s\n"), - prog_string, oinfo, origin, nao); - } - } + val prefix = format(nil, lit("~a:"), prog_string, 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, lit("~a unhandled exception of type ~a:\n"), + prefix, sym, nao); - format(std_error, - if3(is_msg, - lit("~a: message: ~!~a\n"), - lit("~a: exception args: ~!~s\n")), - prog_string, msg_or_args, nao); + error_trace(sym, args, std_error, prefix); } if (uw_exception_subtype_p(sym, query_error_s) || uw_exception_subtype_p(sym, file_error_s)) { |