Thread Subject: How to get debug to catch errors in listener callbacks?

Subject: How to get debug to catch errors in listener callbacks?

From: Nick

Date: 6 Dec, 2008 01:14:17

Message: 1 of 6

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...

Cheers,
Nick

Subject: How to get debug to catch errors in listener callbacks?

From: Steven Lord

Date: 8 Dec, 2008 16:10:12

Message: 2 of 6


"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

Subject: How to get debug to catch errors in listener callbacks?

From: Nick

Date: 8 Dec, 2008 19:50:23

Message: 3 of 6

Thanks for the response Steve,

Unfortunately the type of error thrown by 'MyLazyCallback' is not reported, just that there is an error at the notify line. This is also where all the debugging tools will stop/catch any errors. Thus far I've just been commenting each of my notify commands with a list of all listeners to remind me in case something goes awry.

Subject: How to get debug to catch errors in listener callbacks?

From: Jacob Katz

Date: 1 Aug, 2009 17:40:19

Message: 4 of 6

Did you ever find a solution to this problem? I am running into the same difficulty and I would be happy to find a more elegant solution than adding comments.

Thanks!

Nick <nickchng@gmail.com> wrote in message <24234126.1228765854213.JavaMail.jakarta@nitrogen.mathforum.org>...
> Thanks for the response Steve,
>
> Unfortunately the type of error thrown by 'MyLazyCallback' is not reported, just that there is an error at the notify line. This is also where all the debugging tools will stop/catch any errors. Thus far I've just been commenting each of my notify commands with a list of all listeners to remind me in case something goes awry.

Subject: How to get debug to catch errors in listener callbacks?

From: Ryan Ollos

Date: 5 Aug, 2009 01:10:07

Message: 5 of 6

"Jacob Katz" <idahopotato_removeme_@gmail.com> wrote in message <h51um3$2fl$1@fred.mathworks.com>...
> Did you ever find a solution to this problem? I am running into the same difficulty and I would be happy to find a more elegant solution than adding comments.

I think it would be worth talking with Mathworks technical support. I'd be happy to open a case with them, but we should probably put together a simple example to demonstrate the issue. All of the cases I have that might demonstrate the issue are pretty extensive pieces of code.

Subject: How to get debug to catch errors in listener callbacks?

From: Ryan Ollos

Date: 28 Oct, 2009 04:46:01

Message: 6 of 6

"Jacob Katz" <idahopotato_removeme_@gmail.com> wrote in message <h51um3$2fl$1@fred.mathworks.com>...
> Did you ever find a solution to this problem? I am running into the same difficulty and I would be happy to find a more elegant solution than adding comments.

I believe this has been fixed as of r2009b.

Tags for this Thread

Everyone's Tags:

oop

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
oop per isakson 13 Jan, 2009 17:41:11
rssFeed for this Thread

Contact us at files@mathworks.com