This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

scm_cur_loadp in an error hander


Hello,

I would like to display some file information in my application
if an error occured during file loading.  I used scm_internal_catch
and defined the error hander like this:

static SCM
error_handler (void *handler_data, SCM tag, SCM throw_args)
{
  if (scm_cur_loadp != SCM_BOOL_F)
    {
      scm_port *port = SCM_PTAB_ENTRY (scm_cur_loadp);
      printf ("%s:%d:%d: ",
              SCM_CHARS (port->file_name),
	      port->line_number,
              port->column_number);
    }

  ...
}

This doesn't work.  Whenever the handler is called, the value of
scm_cur_loadp is reset to SCM_BOOL_F (due to dynamic-wind ?).

I guess one way to do my task is:

 1. Create a new variable scm_err_loadp.

 2. Define scm_primitive_load so as to use scm_internal_catch
    in addition to (or instead of) scm_internal_dynamic_wind.

 3. Set scm_err_loadp to scm_cur_loadp in the hander before
    reseting scm_cur_loadp to the previous value.

 4. Refer to scm_err_loadp in my own hander.

I think, if it works, this is generally useful because people
(especially me) often make trivial mistakes in a file and want to
know where the error is.

Could this be implemented?

Thanks,
Keisuke Nishida

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]