Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Error lands in debugger instead?
Date: Tue, 9 Oct 2007 19:43:15 +0000 (UTC)
Organization: TACT Computer Systems Ltd
Lines: 63
Message-ID: <feglkj$st2$1@fred.mathworks.com>
References: <feg1fq$ptf$1@fred.mathworks.com> <feg29n$ag6$1@fred.mathworks.com> <feg9pk$95b$1@fred.mathworks.com> <fegdna$aeu$1@canopus.cc.umanitoba.ca> <feghi8$mnu$1@fred.mathworks.com> <feginv$gp1$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-06-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1191958995 29602 172.30.248.36 (9 Oct 2007 19:43:15 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 9 Oct 2007 19:43:15 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 642467
Xref: news.mathworks.com comp.soft-sys.matlab:432083



"Darik " <dgambleDEL@uwaterlooDEL.caDEL> wrote in message
<feginv$gp1$1@fred.mathworks.com>...
> "Darik " <dgambleDEL@uwaterlooDEL.caDEL> wrote in message 
> <feghi8$mnu$1@fred.mathworks.com>...
> > roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in 
> > message <fegdna$aeu$1@canopus.cc.umanitoba.ca>...
> > > In article <feg9pk$95b$1@fred.mathworks.com>,
> > > Darik  <dgambleDEL@uwaterlooDEL.caDEL> wrote:
> > > >Using dbstop if error will result in the debugger 
> > stopping 
> > > >at the SET command, not at the line in the set 
> function 
> > > >causing the error. Does anyone know if there's a way 
> to 
> > > >have the debugger stop in the set function?
> > > 
> > > set() is normally a built-in function, not coded in 
> > matlab.
> > > 
> > 
> > Yeah, I know. Using schema.prop to add custom graphics 
> > properties is an undocumented feature. In the code 
> snippet 
> > I posted, the built-in SET function calls the user 
> defined 
> > function mySetFunction.
> 
> Sorry, just realized I wasn't as clear here as I should've 
> been. I'd like the debugger to stop at the line in 
> MYSETFUNCTION that causes the error, NOT earlier in the 
> stack in the parent function that calls the SET function.


Schema.prop handlers only receive the object handle and
suggested value as their first 2 args - no evt field. They
also have a generic try-catch mechanism that causes errors
to propagate upward to their caller (=your set call), which
is why you dbstop there. You can trick this by having your
own error-handling code segment, as follows:

function val = mySetFunction (h, val)
  try
    % do something
  catch
    err = lasterror;
    keyboard;  % inspect err struct here
  end

BTW, you can specify additional handler params, as follows:

prop.SetFunction = {@mySetFunction,data1,data2};
...
function val = mySetFunction(prop,val,d1,d2)

All this is (as stated above) entirely undocumented and
unsupported. You can see some usage ideas in a few of my
File Exchange submissions
(http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14583
for example).

Yair Altman
http://ymasoftware.com