Wed 14 Aug 2013 05:28:50 PM UTC, comment #5:
I suppose this is OK as a temporary solution until we have classdef working and can actually define a proper MException object. I pushed the change with a few minor changes (commit message and a fix for an apparent cut and paste error in the pt-check file and an addition to the NEWS file).
http://hg.savannah.gnu.org/hgweb/octave/rev/923ce8b42db2
Stefan,
Please take a look at the changes I made to the commit message and try to follow that style and format in the future. Thanks.
We also need to update the manual for this change. Could you please take a look at doing that?
|
Tue 13 Aug 2013 07:00:20 PM UTC, comment #4:
Stefan,
I tried your patch. It works for me.
Since I'm unfamiliar with this part of the code, I suggest you have Jordi, Rik, or jwe look it over and push it.
|
Tue 03 Jan 2012 08:40:33 AM UTC, comment #1:
I think this is an important compatibility issue.
my_caught_error() is a nice idea but it is rather risky. If there are more than one try-catch block in a workspace, it will not work properly unless the user is careful enough to clear my_caught_error. For example:
try,
TRYBLOCK_1;
catch my_caught_error;
CATCHBLOCK; % using my_caught_error instead of lasterror
end
try,
TRYBLOCK_2;
catch my_caught_error;
% my_caught_error is not valid, it is still the error structure generated at TRYBLOCK_1.
end
|
Tue 03 May 2011 01:58:05 PM UTC, original submission:
Syntax like the following doesn't work in Octave (which is OK in Matlab R2007b and onwards without warning/error):
It seems that Matlab changed the way its error handling syntax works from
to
So, as an aside, the return value of lasterror maybe should be of type MException (at least for full compatibility between current releases of Matlab and Octave)?
As a temporary solution I'm using, I've added a function to the path:
which can then be used as follows:
Given that Matlab overrides function names in the lookup table with local variables, the function is never called (the interpreter assigns the MException object to the my_caught_error variable/name). In Octave the function is called and then, in the calling workspace (containing the try/catch/end construction), assigns the value of lasterror to my_caught_error. Given that this is a function call, it is important to use a semicolon after the function call/variable name, for otherwise the result will be displayed! Luckily, Matlab does not mind (given that it also, even if grudgingly, supports empty statements).
|