I have written a MEX function in C++ that uses try/catch error handling. I am catching some exceptions that seem to be thrown by MEX API functions.
For example when I compile and execute the following code MEX-code
#include "mex.h"extern "C" void mexFunction(int nlhs, mxArray*plhs[], int nrhs, const mxArray*prhs[]){ try { mexErrMsgTxt("error message"); } catch (...) { mexPrintf("An exception was thrown.\n"); }}
it produces the following output
??? error message an exception is thrown.
Best Answer