help-octave
[Top][All Lists]
Advanced

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

Re: lasterror (stack.name)


From: gOS
Subject: Re: lasterror (stack.name)
Date: Wed, 4 Jun 2008 08:33:27 -0700 (PDT)

Someone asked me via mail how I got around this and the answer is this,
though the workaround solution that I have is not the answer I seek to my
question:

When a mex function uses mexErrMsgIdAndTxt, the two inputs are 'id' and
'msg'

'msg' is prepended with 'error: foo: ' to become 'error: foo: message'

To extract the name of the failing function I've used the following code:

===========================

le = lasterror;
msg = le.message;
colonPos = strfind(msg,':')
failingFunc = msg((colonPos(1)+2):colonPos(2)-1)

===========================

I added 'MEX' as a mnemonic to the identifier so that it became:
'component:MEX:mnemonic'

Then used the conditional:

if(sum(strfind(le.identifier,'MEX')))

to determine whether I needed to handle the error reporting differently. Its
a hastle, makes code uglier, etc., but it works and I don't see another way
around this.


gOS wrote:
> 
> I've noticed that when I run a mex file (foo.mex) and have it call
> mexErrMsgIdAndTxt('component:mnemonic','message'), that I am receiving
> unexpected values from last error.
> 
> For the sake of this example, assume moo.m calls foo.
> 
> function moo
> 
>   output = foo(input)
>   le = lasterror
> 
> end
> =========================
> 
> le =
> {
>    message = error: foo: message
>    identifier = component:mnemonic
>    stack =
>    {
>       file = C:\file\blah\...\moo.m
>       name = moo
>       line = 3
>       column = 8
>    }
> }
> 
> ===============
> 
> As you can see, foo is referenced in the error message, but does not get
> credit in the stack. Instead, moo is determined to be the offending
> function. I understand line & column would not have values when
> referencing a mex function, but it makes writing a function like
> handleError() a little more difficult if I can't trust the stack to always
> return the correct information or if I have to parse message to find out
> what the actual function was that crashed.
> 
> I suppose, its possible to program all the desired information into the
> identifier when using mex files, but I still wanted to check if this was
> the expected behavior.
> 

-- 
View this message in context: 
http://www.nabble.com/lasterror-%28stack.name%29-tp17647642p17649608.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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