bugGNU Octave - Bugs: bug #67584, Error does not display error...

 
 

bug #67584: Error does not display error message when called from class method

Submitter:  Andreas Bertsatos <pr0m1th3as>
Submitted:  Mon 06 Oct 2025 03:23:37 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Missed Error or Warning
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Mon 06 Oct 2025 03:23:37 PM UTC, original submission:  

This bug report relates to a discussion at discourse.


I came across a case where an error, although executed, does not show the message. Instead, a generic error message pointing to the class method is shown.

This case relates to the cat method from the string class from the datatypes package, which overloads the core cat function. It works as expected,

>> a = string({'asd', 'a'})
a =
  1x2 string array

    "asd"    "a"

>> [a 11]
ans =
  1x3 string array

    "asd"    "a"    "11"

>> [a 11 missing]
ans =
  1x4 string array

    "asd"    "a"    "11"    <missing>

>> [a 11 {1}]
ans =
  1x4 string array

    "asd"    "a"    "11"    "1"

>> [a 11 {duration(0,0,1)}]
ans =
  1x4 string array

    "asd"    "a"    "11"    "00:00:01"

but when an error is supposed to be thrown, then I get the following error

[a 11 @(x)x]
error: string/horzcat method failed
error: called from
    cat at line 1391 column 13
    horzcat at line 1418 column 11

At line 1391, I have the following code:

error ("string.cat: cannot concatenate string arrays with '%s'.", ...
                   class (args{i}));

In debugging mode, the function reaches at the point as expected, if I call the error line inside the debugger, it shows properly,

>> [a 11 @(x)x]
stopped in cat at line 1391 [/home/promitheas/Octave/datatypes/inst/string.m]
1391:             error ("string.cat: cannot concatenate string arrays with '%s'.", ...
debug> error ("string.cat: cannot concatenate string arrays with '%s'.", ...
                   class (args{i}));
error: string.cat: cannot concatenate string arrays with 'function_handle'.
error: called from
    cat at line 1391 column 13
    horzcat at line 1418 column 11
debug>

but as soon as I continue, I get

error: parse error:

  syntax error

>>>                    class (args{i}));
                                      ^
error: string/horzcat method failed
error: called from
    cat at line 1391 column 13
    horzcat at line 1418 column 11

I don’t see any reason for this syntax error. But even if I change the line 1931 to

error ("string.cat: cannot concatenate string arrays with 's'.");

I don’t get the syntax error, but I get the following

>> [a 11 @(x)x]
debug> error ("string.cat: cannot concatenate string arrays with 's'.");
error: string.cat: cannot concatenate string arrays with 's'.
error: called from
    cat at line 1391 column 13
    horzcat at line 1418 column 11
debug>

and subsequently


error: string/horzcat method failed
error: called from
    cat at line 1391 column 13
    horzcat at line 1418 column 11

Any clues what is going on here and how can I circumvent this??

some clues from the discussion at discourse


@jwe already pointed out that this might have to do with a catch statement in the interpreter that intercepts the original error and throws the one you eventually see without propagating your original error.

@rik pointed to data.cc:1801

  if (fcn.is_defined ())
    {
      // Have method for dominant type.  Call it and let it handle conversions.

      octave_value_list tmp2;

      try
        {
          tmp2 = interp.feval (fcn, ovl, 1);
        }
      catch (execution_exception& ee)
        {
          error (ee, "%s/%s method failed", dtype.c_str (), cattype.c_str ());
        }

      if (tmp2.empty ())
        error ("%s/%s method did not return a value", dtype.c_str (),
               cattype.c_str ());

      retval = tmp2(0);
    }

that might be responsible.

Andreas Bertsatos <pr0m1th3as>

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

Carbon-Copy List
  • -email is unavailable- added by pr0m1th3as (Submitted the item)
  •  

    Votes

    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.

     

    History

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.16.
    Corresponding source code