# Why does zend_call_function return SUCCESS if an exception is thrown

- Thread: https://externals.io/message/51849
- Original archive: https://news-web.php.net/php.internals/51849
- Started by Herman Radtke on 2011-04-09T16:03:16+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #51849 — Herman Radtke — 2011-04-09T16:03:16+00:00

URL: https://externals.io/message/51849#51849

An extension is using zend_call_function to call a userland function.
If the userland function throws an exception, zend_call_function will
still return SUCCESS.  Why isn't zend_call_function returning FAILURE
on an exception?  Is there a way to check if an exception was thrown
after zend_call_function returns a SUCCESS?

For reference I am looking in Zend/zend_execute_API.c:
        if (EG(exception)) {
                zend_throw_exception_internal(NULL TSRMLS_CC);
        }
        return SUCCESS;

-- 
Herman Radtke
hermanradtke@gmail.com | http://hermanradtke.com

---

## #51850 — Gustavo Lopes — 2011-04-09T16:19:44+00:00

URL: https://externals.io/message/51849#51850 · In reply to: #51849

On Sat, 09 Apr 2011 17:03:16 +0100, Herman Radtke <hermanradtke@gmail.com>  
wrote:

> An extension is using zend_call_function to call a userland function.
> If the userland function throws an exception, zend_call_function will
> still return SUCCESS.  Why isn't zend_call_function returning FAILURE
> on an exception?  Is there a way to check if an exception was thrown
> after zend_call_function returns a SUCCESS?
>
Because what "success" means in this context is that the function could be  
executed. If you see the implementation of zend_call_function, you'll  
notice the conditions that return FAILURE are those where the execution of  
the target function doesn't even begin.

You can check for exceptions via EG(exception).

-- 
Gustavo Lopes

---

## #51851 — Herman Radtke — 2011-04-09T16:52:32+00:00

URL: https://externals.io/message/51849#51851 · In reply to: #51850

> Because what "success" means in this context is that the function could be
> executed. If you see the implementation of zend_call_function, you'll notice
> the conditions that return FAILURE are those where the execution of the
> target function doesn't even begin.
>
> You can check for exceptions via EG(exception).

Perfect, thank you.

-- 
Herman Radtke
hermanradtke@gmail.com | http://hermanradtke.com
