octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63807] Add function throw() for Matlab Compat


From: Rik
Subject: [Octave-bug-tracker] [bug #63807] Add function throw() for Matlab Compatibility
Date: Tue, 14 Feb 2023 11:19:36 -0500 (EST)

URL:
  <https://savannah.gnu.org/bugs/?63807>

                 Summary: Add function throw() for Matlab Compatibility
                 Project: GNU Octave
               Submitter: rik5
               Submitted: Tue 14 Feb 2023 08:19:34 AM PST
                Category: Octave Function
                Severity: 1 - Wish
                Priority: 5 - Normal
              Item Group: Feature Request
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: dev
         Discussion Lock: Any
        Operating System: Any
           Fixed Release: None
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Tue 14 Feb 2023 08:19:34 AM PST By: Rik <rik5>
Octave has the function rethrow(EXCEPTION) which throws an exception using the
provided EXCEPTION structure.  When rethrowing an exception, Octave uses the
stack field from the structure which points to where the exception originated.
 Matlab has an additional function throw(EXCEPTION) which throws an exception,
but the stack field contains the location where the throw() command was
executed.  An example:


try
  error ("emitting an error");   # line 2
catch EXCEPTION
  rethrow (EXCEPTION);           # line 4
  #throw (EXCEPTION);             # line 5
end


Output in Octave is


error: emitting an error
error: called from
    tst_throw at line 2 column 3


If rethrow() is commented out and throw() existed then the output would be


error: emitting an error
error: called from
    tst_throw at line 5 column 3


This seems like a relatively easy function to add since, for example, the
error() function already has the code to figure out where it is being called
from in an m-file.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63807>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]