jed-users mailing list

[2021 Date Index] [2021 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [jed-users] How to get the line where the error occured?


Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
> I want to get the line n number information after detecting the error with
> SLang_get_error() (i.e.: at the C level). Is this possible?
>
> What I'm aiming at are line num equipped error messages in my full screen
> terminal app.

When an uncaught interpreter exception occurs and the hook `SLang_Dump_Routine`
is non-null, then the slang library call that hook with the error
message that contains various information about the exception.  The
C code in the jed editor sets the value of `SLang_Dump_Routine` to
`jed_traceback`, i.e.,

   SLang_Dump_Routine = jed_traceback;

The jed_traceback function simply inserts the contents of the message
in the *traceback* buffer:

static void jed_traceback (SLFUTURE_CONST char *s)
{
   /* insert the string `s` into the *traceback* buffer */
      .
      .
}

The level of detail of the message is controlled by the value of the
_traceback variable (SLang_Traceback in the C API).  When you set this
variable to 4 (see the _traceback documentation for supported values),
then a minimal traceback message will get generated:

   Traceback: <name-of-function>
   <file>:<line-number>:<function>:<error-message>

With that background, I suggest that you create a hook such as the one
above and log the messages received by it.

By the way, I think this is off-topic for this group, which pertains
the the jed-editor.  A better list is the slang-users one since it is
devoted to those whose use the library in their own software.  Please
see <https://www.jedsoft.org/slang/mailinglists.html> for more
information.

I hope that this helps.

Thanks,
--John
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.


[2021 date index] [2021 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]