This is the mail archive of the
mailing list for the Guile project.
Re: Catching an error
- To: firstname.lastname@example.org
- Subject: Re: Catching an error
- From: "Eric M. Ludlam" <email@example.com>
- Date: Fri, 21 May 1999 16:13:04 -0400
- CC: firstname.lastname@example.org
- References: <199905211901.VAA23047@piment.ens-lyon.fr>
- Reply-to: email@example.com
>>> Alexandre Guillemet <firstname.lastname@example.org> seems to think that:
>I work with the 1.2 version of guile.
>I don't know to use the function : gh_eval_str_with_catch
>What is exactly the type scm_catch_handler_t ?
>I need to catch the error provide by an syntaxic error in a C string.
>There's nothing about it in the tutorial and other docs I found.
[ ... ]
If I recall correctly the function gh_eval_str_with_catch does not
work as advertised (or not advertised in this case) in 1.2. You can
get the same behavior with the attached code snippet. "catcher" is a
function to run when there is an error. cs_eval_str is the function
you call with a C string.
The output of catcher is my own devising, and isn't as helpful as I'd
necessarily like. Also, you don't have to use the stack version of
the catch routine. I just happen to like stack traces. :)
static SCM catcher(void *data, SCM tag, SCM throw_args)
SCM port = scm_current_output_port(); /* set this to whatever */
/* Throw args seem to be: ( FN FORMAT ARGS #f )
scm_puts("Function: ", port);
scm_puts(", ", port);
tmp = gh_cadr(throw_args);
scm_puts("Error: ", port);
scm_display_error_message(tmp, gh_caddr(throw_args), port);
scm_puts("Other Data: ", port);
the_stack = scm_fluid_ref(SCM_CDR(scm_the_last_stack_fluid));
scm_display_backtrace(the_stack, port, SCM_UNDEFINED, SCM_UNDEFINED);
void cs_eval_str(char *str)
scm_internal_stack_catch (SCM_BOOL_T, (scm_catch_body_t) gh_eval_str, str,
(scm_catch_handler_t) catcher, str);