[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: error catching
From: |
Steve Tell |
Subject: |
Re: error catching |
Date: |
Tue, 26 Feb 2002 23:30:18 -0500 (EST) |
On Sun, 17 Feb 2002, Gurer Ozen wrote:
>
> Hi, I'm adding guile support to my video player program.
> I have some problems with error handling.
>
> I'm executing scheme script files with
> gh_eval_file_with_catch(filename, catcher);
> where catcher is a function like:
> static SCM catcher(void *data, SCM tag, SCM throw_args)
> {
> printf("Error in scheme script!\n");
> }
> This makes it possible to continue the execution of main
> program even if script is buggy or user makes an error and
> selects some other file. But I want something more.
>
> How can I create and print a more detailed error message
> inside this function? I've looked libguile code (throw.c), but
> it is somewhat complex and using scm_ interfaces.
I've been wondering the _right_ answer to this myself.
In a couple of guile-using programs I've written, I've made use of a
sizable of code that I borrowed from the guile-based "scwm" window
manager. Slowly I've been trying to understand this code, motivated
most recently by the fact that it didn't compile under guile-1.5.4.
When I get it figured out, writing down what I know might turn out to be a
useful explanation of using scm_internal_cwdr() and
scm_internal_stack_catch() from C code.
I believe that a simple answer to your question may be to try using the
libguile function
scm_handle_by_message_noexit (void *handler_data, SCM tag, SCM args)
as your error handler instead of your catcher() routine. It can print the
filename and line where the error occured, and possibly a stack traceback.
(this and the helper routine it calls are some of the more understandable
parts of throw.c)
Experts please tell me if I'm off base here...
--
Steve Tell address@hidden
- error catching, Gurer Ozen, 2002/02/16
- Re: error catching,
Steve Tell <=