slang-users mailing list

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

[slang-users] err.line not set for try (err) on stack underflow


Hi,
 
While writing a script for SLang 2 using try/catch exception handling, I've
found a small glitch: the exception object does not contains line
information for some stack underflow errors.
 
There is a test case: function f1() generates a stack underflow calling a
user-defined function without enough parameters. f2() does the same calling
an intrinsic function, and f3() generates a completely different error (just
for reference).

---- cut here (under.sl)
_debug_info = 1;
_traceback = 1;

define fun(a) {} 

define f1() { fun(); }
define f2() { message(()); }
define f3() { () = "a" + 1; }

define test(f)
{
   variable e;
   
   try (e) {
      @f();
   } catch AnyError: {
      vmessage("test(%s): Caught %s, at %s:%d = %s", string(f), e.descr,
e.file, e.line, string(e.message));
   }
}

if (__argc != 2)
   message("usage: slsh under.sl testnumber");
else {
   message(" ---- error trapped with try...");
   eval("test(&f"+__argv[1]+")");
   message(" ---- standard error traceback");
   eval("f"+__argv[1]);
}
---- cut here


And there is a transcript of a session:

dino@thor:~> slsh --version
slsh version 0.7.2-0
S-Lang Library Version: 2.0.0 pre-release candidate 7 Mar 24 2005
LLOYD dino@thor:~> slsh under.sl 1
 ---- error trapped with try...
test(&f1): Caught Stack Underflow Error, at ./under.sl:-1 =
 ---- standard error traceback
  Local Variables:
        Undefined_Type a = Undefined_Type
./under.sl:6:f1:Stack Underflow Error
***string***:2:<top-level>:Stack Underflow Error
called from eval: f1
Traceback: eval

dino@thor:~> slsh under.sl 2
 ---- error trapped with try...
test(&f2): Caught Stack Underflow Error, at ./under.sl:7 =
 ---- standard error traceback
Traceback: message
./under.sl:7:f2:Stack Underflow Error
***string***:2:<top-level>:Stack Underflow Error
called from eval: f2
Traceback: eval

dino@thor:~> slsh under.sl 3
 ---- error trapped with try...
test(&f3): Caught Type Mismatch, at ./under.sl:8 = String_Type +
Integer_Type is
 not possible
 ---- standard error traceback
String_Type + Integer_Type is not possible
./under.sl:8:f3:Type Mismatch
***string***:2:<top-level>:Type Mismatch
called from eval: f3
Traceback: eval


This also happens without eval() and function references, I wrote it that
way to make it shorter.

It's not a very big problem, but is a bit annoying, as the traceback
contains that info.

Thanks,
								Dino

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


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