From 802d65b8e0711ccd3eb3e6e722932937fc74c6c4 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 30 Jul 2012 16:24:55 -0400 Subject: [PATCH] better reporting of bootstrap errors. would have prevented #1089. --- src/julia.expmap | 3 +++ src/julia.h | 6 +++--- ui/repl.c | 21 +++++++++++++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/julia.expmap b/src/julia.expmap index 412c07834e81f..bb6d97d460705 100644 --- a/src/julia.expmap +++ b/src/julia.expmap @@ -181,6 +181,9 @@ jl_get_current_task; jl_enter_handler; jl_exception_in_transit; + jl_errorexception_type; + jl_loaderror_type; + jl_backtrace_type; jl_show; jl_show_any; jl_print_symbol; diff --git a/src/julia.h b/src/julia.h index 2945136a77501..ce5d8da89bf78 100644 --- a/src/julia.h +++ b/src/julia.h @@ -342,10 +342,10 @@ extern jl_typename_t *jl_array_typename; extern jl_struct_type_t *jl_weakref_type; extern jl_struct_type_t *jl_ascii_string_type; extern jl_struct_type_t *jl_utf8_string_type; -extern jl_struct_type_t *jl_errorexception_type; +extern DLLEXPORT jl_struct_type_t *jl_errorexception_type; extern jl_struct_type_t *jl_typeerror_type; -extern jl_struct_type_t *jl_loaderror_type; -extern jl_struct_type_t *jl_backtrace_type; +extern DLLEXPORT jl_struct_type_t *jl_loaderror_type; +extern DLLEXPORT jl_struct_type_t *jl_backtrace_type; extern jl_value_t *jl_stackovf_exception; extern jl_value_t *jl_memory_exception; extern jl_value_t *jl_divbyzero_exception; diff --git a/ui/repl.c b/ui/repl.c index c26c1ae4520e4..09f5afb07ccf2 100644 --- a/ui/repl.c +++ b/ui/repl.c @@ -147,11 +147,28 @@ static int exec_program(void) //jl_lisp_prompt(); //return 1; jl_value_t *errs = jl_stderr_obj(); + jl_value_t *e = jl_exception_in_transit; if (errs != NULL) { - jl_show(jl_stderr_obj(), jl_exception_in_transit); + jl_show(jl_stderr_obj(), e); } else { - ios_printf(ios_stderr, "error during bootstrap\n"); + while (1) { + if (jl_typeof(e) == (jl_type_t*)jl_loaderror_type) { + e = jl_fieldref(e, 2); + // TODO: show file and line + } + else if (jl_typeof(e) == (jl_type_t*)jl_backtrace_type) { + e = jl_fieldref(e, 0); + } + else break; + } + if (jl_typeof(e) == (jl_type_t*)jl_errorexception_type) { + ios_printf(ios_stderr, "error during bootstrap: %s\n", + jl_string_data(jl_fieldref(e,0))); + } + else { + ios_printf(ios_stderr, "error during bootstrap\n"); + } } ios_printf(ios_stderr, "\n"); JL_EH_POP();