Delayed exception
| From: | Piotr Pokora | Date: | Sun, 24 Feb 2008 09:49:39 +0000 |
| Subject: | Delayed exception | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-5129@lists.php.net to get a copy of this message | ||
Hi!
Here's pseudo code (C) in php extension:
foo()
{
g_signal_emit(GObject, signal_id);
bar();
}
And PHP pseudo code :
function my_callback($obj)
{
throw new Exception("DADA");
echo "A";
}
$obj->connect(signal_id, m_callback);
$obj->foo();
Method foo is executed.
'A' is echoed.
bar() is executed;
Exception with 'DADA' message is thrown.
Can anyone explain me why exception is thrown in such undefined order?
I did such workaround in extension:
g_signal_emit(GObject, signal_id);
if(EG(exception))
zend_exception_error(EG(exception) TSRMLS_CC);
bar();
Should I always throw exception explicitly from extension's level?
Piotras