poor line numbering in error messages when using unwind_protect
Søren Hauberg
soren at hauberg.org
Sun Feb 1 10:12:08 CST 2009
Hi
Consider the following function (also attached)
function badlinenumber ()
unwind_protect
error ("this raises and error at line 3");
unwind_protect_cleanup
end_unwind_protect
endfunction
When I run it I get the following error message
error: this raises and error at line 3
error: called from:
error: /home/sh/Skrivebord/badlinenumber.m at line 2, column 3
I would expect the last line to say "line 3, ..." instead of "line
2, ...".
I see something similar with try-catch statements. Consider (also
attached)
function badlinenumber2 ()
try
error ("this raises and error at line 3");
catch
disp (lasterror ()(1).stack.line);
end_try_catch
endfunction
When I call this function I get '2' where I would expect '3'.
Now that I'm testing this I see the same issue with 'for' loops,
function badlinenumber3 ()
for k = 1:10
error ("this raises and error at line 3");
endfor
endfunction
which once again gives me an error at line 2 instead of 3.
Søren
-------------- next part --------------
A non-text attachment was scrubbed...
Name: badlinenumber.m
Type: text/x-matlab
Size: 148 bytes
Desc: not available
Url : https://www-old.cae.wisc.edu/pipermail/bug-octave/attachments/20090201/ea9c5ceb/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: badlinenumber2.m
Type: text/x-matlab
Size: 155 bytes
Desc: not available
Url : https://www-old.cae.wisc.edu/pipermail/bug-octave/attachments/20090201/ea9c5ceb/attachment-0001.bin
More information about the Bug-octave
mailing list