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

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

[Octave-bug-tracker] [bug #48949] mexCallMATLABWithTrap not implemented


From: Guillaume
Subject: [Octave-bug-tracker] [bug #48949] mexCallMATLABWithTrap not implemented and problem with mexCallMATLAB/mexSetTrapFlag
Date: Mon, 5 Sep 2016 16:32:21 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0

Follow-up Comment #2, bug #48949 (project octave):

I actually conflated two issues in this bug report: one bug with mexCallMATLAB
and a feature request with mexCallMATLABWithTrap.

* bug report concerning mexCallMATLAB:
The integer value returned by mexCallMATLAB is always 1 even if an error has
been caught. This can be fixed with the following (this is what mexEvalString
does):


diff -r dc4e2203cd15 libinterp/corefcn/mex.cc
--- a/libinterp/corefcn/mex.cc  Mon Aug 29 14:32:22 2016 -0700
+++ b/libinterp/corefcn/mex.cc  Tue Aug 30 14:30:37 2016 +0100
@@ -3072,7 +3072,11 @@
   catch (const octave::execution_exception&)
     {
       if (mex_context->trap_feval_error)
-        recover_from_exception ();
+        {
+          recover_from_exception ();
+          
+          execution_error = true;
+        }
       else
         {
           args.resize (0);


* feature request for mexCallMATLABWithTrap:
Given that the try/catch ME currently returns a structure, the following could
be used until a complete MException can be returned:


mxArray *mexCallMATLABWithTrap(int nlhs, mxArray *plhs[], int nrhs, mxArray
*prhs[], const char *functionName) {
    mxArray *mx = NULL;
    const char **fields = (const char *[]){"identifier", "message", "case",
"stack"};
    mexSetTrapFlag(1);
    if (mexCallMATLAB(nlhs, plhs, nrhs, prhs, functionName)) {
        mx = mxCreateStructMatrix(1, 1, 4, fields);
        mxSetFieldByNumber(mx, 0, 0, mxCreateString("MATLAB:error"));
        mxSetFieldByNumber(mx, 0, 1, mxCreateString(functionName));
        mxSetFieldByNumber(mx, 0, 2, mxCreateCellMatrix(0, 0));
        mxSetFieldByNumber(mx, 0, 3, mxCreateStructMatrix(0, 1, 0, NULL));
        return mx;
    }
    else {
        return NULL;
    }
}


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48949>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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