Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to get debug to catch errors in listener callbacks?
Date: Mon, 8 Dec 2008 11:10:12 -0500
Organization: The MathWorks, Inc.
Lines: 31
Message-ID: <ghjgt4$fol$1@fred.mathworks.com>
References: <12196427.1228526088516.JavaMail.jakarta@nitrogen.mathforum.org>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1228752612 16149 144.212.105.187 (8 Dec 2008 16:10:12 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 8 Dec 2008 16:10:12 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:505631



"Nick" <nickchng@gmail.com> wrote in message 
news:12196427.1228526088516.JavaMail.jakarta@nitrogen.mathforum.org...
> Say I add a listener to an event called 'hello', defined for some object, 
> 'obj':
>
> addlistener(obj, 'hello', @(src, evnt)MyLazyCallback(src, evnt, data));
>
> Now, if there is an error in MyLazyCallback, my Matlab only catches the 
> error at the line where obj is notified:
>
> ->notify(obj, 'hello')
>
> My question:
>
> Is there any way to get Matlab to error inside MyLazyCallback?  It's a bit 
> of a pain right now as I have to go through every callback listening to 
> that event to find the error...

I haven't tried this inside a listener function, but DBSTOP IF ERROR or 
DBSTOP IF CAUGHT ERROR may do what you want (and if you know the error 
identifier for the error that's being thrown by MyLazyCallback, you can 
specify that to control with more granularity where DBSTOP stops.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/dbstop.html

-- 
Steve Lord
slord@mathworks.com