bugGNU Octave - Bugs: bug #47874, error/warning fail when only...

 
 

bug #47874: error/warning fail when only argument looks like an error/warning ID

Submitter:  Robert Jenssen <morgawr>
Submitted:  Sun 08 May 2016 03:11:49 AM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Robert Jenssen Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 14 May 2016 03:20:01 AM UTC, comment #9: 

I applied Lachlan's patch to make the error message a bit clearer (http://hg.savannah.gnu.org/hgweb/octave/rev/b766928062f5).

Since Octave is, indeed, Matlab compatible in producing an error I'm closing the report.

Rik <rik5>
Group administrator
Sat 14 May 2016 12:52:19 AM UTC, comment #8: 

Actually, I'll submit the patch even if it isn't acceptable :)

(file #37152)

Lachlan Andrew <lachlan>
Sat 14 May 2016 12:27:10 AM UTC, comment #7: 

How about just making the usage error more explicit.  If the error message were

"error: call to error with identifier 'XX:YY' requires message"

then the end user would at least get the message that the programmer intended, as well as the programmer getting told to clean up their act.

I'm always puzzled why error messages don't display more readily-available information.

If that is acceptable, I'll write a patch soon.

Lachlan Andrew <lachlan>
Tue 10 May 2016 06:01:28 PM UTC, comment #6: 

Alright, so Octave is doing the right thing here. We could be a little more picky in what we accept as an error identifier, so maybe something like


error ("0:100")


would be allowed. But if you pass a single string that looks like it should be an identifier, then this is a valid usage error.

Anyone care to test whether Matlab accepts something like


error('0:0')
error('1one:two')
error('_:_')
error('_invalid:identifier')
error('Matlab:_asdf')


as an error string? These should not be accepted as identifiers according to the help, so maybe Matlab just prints them as the message?

Mike Miller <mtmiller>
Group Member
Tue 10 May 2016 07:45:06 AM UTC, comment #5: 

In Matlab:


>> error('a:b')
Error using error
If you specify a message identifier argument, you must specify the message
text argument.


Anonymous
Mon 09 May 2016 04:25:34 AM UTC, comment #4: 

I believe that the current Octave behavior matches Matlab.  Can someone please confirm?

John W. Eaton <jwe>
Group administrator
Mon 09 May 2016 01:58:38 AM UTC, comment #3: 

No, I'm afraid I don't have access to Matlab.

IMHO if calling error() with single string argument that contains a ":" causes an error message then that is a bug. The problem arose when I tried to show a vector range in an error message.

Robert Jenssen <morgawr>
Sun 08 May 2016 03:45:27 PM UTC, comment #2: 

Confirmed here, but not sure what the right behavior should be.

Do you have Matlab to test what it does in this scenario? The error/warning ID parsing is meant to be Matlab compatible.

Also note that you can easily work around this by including spaces or other characters that are forbidden in an error/warning identifier.

It could be argued that calling error or warning with a string that is actually meant to be an identifier and missing the message is an error, which is what is reported now.

Mike Miller <mtmiller>
Group Member
Sun 08 May 2016 03:22:48 AM UTC, comment #1: 

Sorry if this report was a bit cryptic. The "doc" for error() has:

It is also possible to assign an identification string to an error.
If an error has such an ID the user can catch this error as will be
shown in the next example.  To assign an ID to an error, simply call
‘error’ with two string arguments, where the first is the identification
string, and the second is the actual error.  Note that error IDs are in
the format "NAMESPACE:ERROR-NAME".


I read this to mean that error should only assume that the first string is an error ID if that string contains a ":" AND there are two string arguments.

Robert Jenssen <morgawr>
Sun 08 May 2016 03:11:49 AM UTC, original submission:  


octave:1> error("a:b")
error: call to error with message identifier requires message
octave:1> warning("a:b")
warning: call to warning with message identifier requires message
octave:2>


Robert Jenssen <morgawr>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #37152:  bug_47874_err_id.cset added by lachlan (864B - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by morgawr (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-05-14 rik5 StatusPatch Submitted Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2016-05-14 lachlan Attached File- Added bug_47874_err_id.cset, #37152
        StatusNeed Info Patch Submitted
    2016-05-08 mtmiller Severity3 - Normal 2 - Minor
        Item GroupNone Matlab Compatibility
        StatusNone Need Info
        Release4.0.2 dev
        Operating SystemGNU/Linux Any
        Summaryerror() fails when string contains a colon error/warning fail when only argument looks like an error/warning ID

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code