bugGNU Octave - Bugs: bug #33217, Matlab's try, ...; catch...

 
 

bug #33217: Matlab's try, ...; catch EXCEPTION, ...; end doesn't work (no support for caught error)

Submitted by:  None
Submitted on:  Tue 03 May 2011 01:58:05 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Jochen WeberOriginator Email: -unavailable-
Open/Closed: ClosedRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Mon 06 Jan 2014 08:56:18 AM UTC, comment #10:

Well, since nobody applied my patch from comment #6, the new description is not completely true.

Stefan Mahr <dac922>
Mon 06 Jan 2014 02:18:23 AM UTC, comment #9:

Thanks, I've slightly edited your patch and its commit message. I also rebased it to the stable branch:

http://hg.savannah.gnu.org/hgweb/octave/rev/6fd22474783e

You may wish to remove your pre-edited patch from your local repo:

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Sun 05 Jan 2014 05:33:49 PM UTC, comment #8:

updating docs

(file #30193)

Felipe G. Nievinski <fgnievinski>
Tue 20 Aug 2013 05:27:03 PM UTC, comment #7:

correct link

http://hg.savannah.gnu.org/hgweb/octave/rev/e6c0ac8ce5b6

Sorry :(

Stefan Mahr <dac922>
Tue 20 Aug 2013 05:24:55 PM UTC, comment #6:

For the sake of completeness: jwe pushed a changeset to fix the parser conflicts introduced by my patch
http://hg.savannah.gnu.org/hgweb/octave/rev/923ce8b42db2

In order to reduce the need of explanation in the manual, attached patch makes the result of 'catch exception' compatible to the result of the lasterror function.

(file #28883)

Stefan Mahr <dac922>
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?

John W. Eaton <jwe>
Project Administrator
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.

Ben Abbott <bpabbott>
Project Member
Tue 13 Aug 2013 05:43:50 PM UTC, comment #3:

Should work now without breaking

(file #28835)

Stefan Mahr <dac922>
Tue 09 Apr 2013 08:27:12 PM UTC, comment #2:

I have attached a patch that hopefully helps to solve this issue. It needs further improvements, e.g. support for err.stack (not exported from error.h yet, so err.message and err.identifier only at the moment).

Stefan Mahr <dac922>
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

Gokberk <gdevel>
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).

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #30193:  doc_catcherr.diff added by fgnievinski (3KiB - application/octet-stream)
file #28883:  catchexception.diff added by dac922 (2KiB - text/x-patch)
file #28835:  trycatch4.diff added by dac922 (9KiB - text/x-patch)
file #27832:  trycatch3.diff added by dac922 (8KiB - text/x-patch)
file #27829:  trycatch2.diff added by dac922 (8KiB - text/x-patch - commit message according commit message guidelines)
file #27828:  trycatch1.diff added by dac922 (7KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by fgnievinski (Updated the item)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by dac922 (Updated the item)
  • -unavailable- added by gdevel (Posted a comment)
  • -unavailable- added by bpabbott (Updated the item)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 11 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 05 Jan 2014 05:33:49 PM UTCfgnievinskiAttached File-=>Added doc_catcherr.diff, #30193
    Tue 20 Aug 2013 05:24:55 PM UTCdac922Attached File-=>Added catchexception.diff, #28883
    Wed 14 Aug 2013 05:28:50 PM UTCjweStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 13 Aug 2013 05:43:50 PM UTCdac922Attached File-=>Added trycatch4.diff, #28835
    Wed 10 Apr 2013 04:48:31 PM UTCdac922Attached File-=>Added trycatch3.diff, #27832
    Tue 09 Apr 2013 08:55:17 PM UTCdac922Attached File-=>Added trycatch2.diff, #27829
    Tue 09 Apr 2013 08:33:49 PM UTCbpabbottRelease3.4.0=>dev
      Operating SystemMac OS=>Any
    Tue 09 Apr 2013 08:23:12 PM UTCdac922Attached File-=>Added trycatch1.diff, #27828
    Sun 18 Sep 2011 05:06:41 PM UTCbpabbottItem GroupFeature Request=>Matlab Compatibility

    Back to the top


    Powered by Savane 3.1-cleanup1