logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: Exceptions disappear when thrown in callback: msg#00179

Subject: Re: Exceptions disappear when thrown in callback
Why do you keep saying "crash miserably"? If you use PEAR::Net_LDAP, you would still be able to catch exceptions inside your callback. The only issue here is uncaught exceptions and for those we would simply quit the current main loop, so you could put try/catch block around gtk::main() and still catch them.

-Andrei


On Mar 17, 2006, at 9:05 AM, Scott Mattocks wrote:

Christian Weiske wrote:
Throwing an unhandled exception is harsh itself. The programmer is
responsible to take care of that, and if there was no main loop, the
program would crash, too.

I agree that you shouldn't throw an unhandled exception and if you do
you deserve to have your application crash, but I am more concerned
about not realizing that you need to catch an exception. If I use some
other package that throws an exception that I didn't know about, my app
will crash miserably. For example, the current implementation of
PEAR::Net_LDAP has a bug that makes it always throw a PEAR_Exception if
a connection cannot be made. I know we shouldn't change PHP-GTK 2 to
compensate for other people's bugs but there are cases where an
exception may be thrown when you don't expect it.

http://pear.php.net/bugs/bug.php?id=4975

Killing the main loop is still better than letting the application hang
so any kind of fix is fine by me. It should probably just be noted in
the connect* docs exactly what will happen when an uncaught exception
occurs during a callback.

By the way, callbacks and exceptions are not unique to PHP-GTK. What
happens if an uncaught exception is thrown in a callback to
register_tick_function() or some other function call that can't be
wrapped in a try/catch block like __wakeup or __destruct?

--
Scott Mattocks
http://www.crisscott.com

--
PHP-GTK Development Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP-GTK Development Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>