[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

exceptions in tk after procs?

Ferenc Engard

11/25/2003 11:00:00 PM

Hello,

There are a few situations when ruby code runs in a way that the raised
exceptions are swallowed by the ruby/tk code (I suppose). I didn't look
much after it, but one of this is when ruby code runs as an 'after'
callback.

Can I somehow globally catch these exceptions? Because if I forget to
place a begin...rescue...TkDialog envelope to the code, these exceptions
are easily overlooked.

Thanks:
Ferenc


6 Answers

Hidetoshi NAGAI

11/27/2003 9:06:00 AM

0

Ferenc Engard

11/29/2003 6:30:00 PM

0

> > There are a few situations when ruby code runs in a way that the raised
> > exceptions are swallowed by the ruby/tk code (I suppose). I didn't look
> > much after it, but one of this is when ruby code runs as an 'after'
> > callback.
>
> TkAfter had a bug on treatment of TkAfter#cancel_on_exception=(mode).
> I fixed it on CVS.
> If you set TkAfter#cancel_on_exception = false, Tk will show an error
> dialog box when the after callback cause an exception.
> The default value of cancel_on_exception is true.

Why? :)

Why should an uncatched exception be quiet? I think that is a
programming error, more often than not. Although, I mostly use TkAfter
for 'after idle', not for repeating tasks, so it is possible that this
alters my point of view.

Thanks for the bugfix.

Ferenc



Hidetoshi NAGAI

11/30/2003 8:40:00 AM

0

Ferenc Engard

11/30/2003 2:35:00 PM

0

> For 'after idle' only, there is 'Tk.after_idle' method.
> It will show an error dialog, when its callback procedure causes an
> exception.

And what about, say, TkEntry's validatecommand functions? It seems that
they work similarly, i.e. discarding the exceptions. (I am not sure
about it right now, but I have a strong suspect. :)

Ferenc



Hidetoshi NAGAI

12/1/2003 3:19:00 AM

0

Ferenc Engard

12/2/2003 11:30:00 PM

0

Oh, I have missed the TkCore's after and after_idle methods. Why did I
suck with the understanding of the overcomplicated TkAfter class...?

I will test if this is good to me. Thanks!

Ferenc

Hidetoshi NAGAI wrote:
> For 'after idle' only, there is 'Tk.after_idle' method.
> It will show an error dialog, when its callback procedure causes an
> exception.