[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Line/column numbers in user supplied exception handlers
From: |
Dale P. Smith |
Subject: |
Line/column numbers in user supplied exception handlers |
Date: |
Sun, 01 Jul 2001 10:40:19 -0400 |
I'm trying to catch exceptions with my own handler and generate error
messages that include file/line number information. If you call the
attached C program with an argument of 0, 1 or 2, you get these
different outputs:
address@hidden:~/$ ./foo 0
foo.scm:3:2: In expression (blorfl):
foo.scm:3:2: Unbound variable: blorfl
address@hidden:~/$ ./foo 1
ERROR: Unbound variable: blorfl
eval file returns: #f
address@hidden:~/$ ./foo 2
[some prefix here] foo.scm: ERROR: Unbound variable: blorfl
eval file returns: #f
I'd like to generate a message like:
[some prefix here] [error] foo.scm:3:2: Unbound variable: blorfl
How do I do it? What's the best way to do this using the scm_
interface?
Thanks!
-Dale
--
Dale P. Smith
Treasurer, Cleveland Linux Users Group http://cleveland.lug.net
Senior Systems Consultant, Altus Technologies Corporation
address@hidden
440-746-9000 x309
#include <guile/gh.h>
SCM
my_handler(void *data, SCM tag, SCM throw_args)
{
SCM ret;
SCM eport = scm_current_error_port();
scm_puts("[some prefix here] ", eport);
scm_puts(data, eport); /* filename */
scm_puts(": ", eport);
ret = scm_handle_by_message_noexit(data, tag, throw_args);
scm_force_output(eport);
return ret;
}
int
main(int argc, char *argv[])
{
int val = atoi(argv[1]);
SCM ret = SCM_EOL;
SCM port = SCM_EOL;
scm_init_guile();
SCM_DEVAL_P = 1;
SCM_RECORD_POSITIONS_P = 1;
SCM_RESET_DEBUG_MODE;
switch (val) {
case 0:
ret = gh_eval_file("foo.scm");
break;
case 1:
ret = gh_eval_file_with_catch("foo.scm",
scm_handle_by_message_noexit);
break;
case 2:
ret = gh_eval_file_with_catch("foo.scm", my_handler);
break;
}
port = scm_current_error_port();
scm_puts("eval file returns: ", port);
scm_prin1(ret, port, 0);
scm_newline(port);
return 0;
}
foo.scm
Description: Lotus Screencam
- Line/column numbers in user supplied exception handlers,
Dale P. Smith <=
- Re: Line/column numbers in user supplied exception handlers, Dale P. Smith, 2001/07/01
- Re: Line/column numbers in user supplied exception handlers, Dale P. Smith, 2001/07/02
- Re: Line/column numbers in user supplied exception handlers, Marius Vollmer, 2001/07/05
- Re: Line/column numbers in user supplied exception handlers, Neil Jerram, 2001/07/06
- Re: Line/column numbers in user supplied exception handlers, Marius Vollmer, 2001/07/06
- Re: Line/column numbers in user supplied exception handlers, Neil Jerram, 2001/07/07