diff options
author | Andy Wingo <wingo@pobox.com> | 2011-02-09 23:34:36 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-02-09 23:36:18 +0100 |
commit | cd4f274c622511ac9b45cd16d6e6a542bd07464c (patch) | |
tree | 85a501ee33e7c3abbd7f6cf97ed97085ffa24dea /libguile/throw.c | |
parent | eaf2d3f25323a55153abd1d44f6943249de2d2a9 (diff) | |
download | guile-cd4f274c622511ac9b45cd16d6e6a542bd07464c.tar.gz |
more robust fallback error printer
* libguile/throw.c (pre_init_throw): Deal with errors printing the
exception.
Diffstat (limited to 'libguile/throw.c')
-rw-r--r-- | libguile/throw.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libguile/throw.c b/libguile/throw.c index 486228e54..b5931fb63 100644 --- a/libguile/throw.c +++ b/libguile/throw.c @@ -566,8 +566,28 @@ pre_init_throw (SCM k, SCM args) return scm_at_abort (sym_pre_init_catch_tag, scm_cons (k, args)); else { - fprintf (stderr, "Throw without catch before boot:\n"); - scm_handle_by_message_noexit (NULL, k, args); + static int error_printing_error = 0; + static int error_printing_fallback = 0; + + if (error_printing_fallback) + fprintf (stderr, "\nFailed to print exception.\n"); + else if (error_printing_error) + { + fprintf (stderr, "\nError while printing exception:\n"); + error_printing_fallback = 1; + fprintf (stderr, "Key: "); + scm_write (k, scm_current_error_port ()); + fprintf (stderr, ", args: "); + scm_write (args, scm_current_error_port ()); + scm_newline (scm_current_error_port ()); + } + else + { + fprintf (stderr, "Throw without catch before boot:\n"); + error_printing_error = 1; + scm_handle_by_message_noexit (NULL, k, args); + } + fprintf (stderr, "Aborting.\n"); abort (); return SCM_BOOL_F; /* not reached */ |