diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-12-30 06:06:51 -0800 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-12-30 06:06:51 -0800 |
commit | 678fb09044c87a2f4bf843bb55eb4b057f1c131a (patch) | |
tree | 31d23b285b4215a1a563b6338e2ac086e07f6736 /src/value.cpp | |
parent | 00be9c5573d6858c89e2f305b4504b0a477ff230 (diff) |
exceptions thrown in PHP code can now be caugth and processed by C++ code
Diffstat (limited to 'src/value.cpp')
-rw-r--r-- | src/value.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/value.cpp b/src/value.cpp index 194934d..49c9c2b 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -868,14 +868,17 @@ Value Value::exec(int argc, zval ***params) // the return zval zval *retval = nullptr; + // the current exception + zval *oldException = EG(exception); + // call the function if (call_user_function_ex(CG(function_table), NULL, _val, &retval, argc, params, 1, NULL) != SUCCESS) return nullptr; - // was a value returned? - if (retval) return Value(retval); + // was an exception thrown? + if (oldException != EG(exception)) throw OrigException(EG(exception)); - // no value was returned, return NULL - return nullptr; + // no (additional) exception was thrown + return retval ? Value(retval) : nullptr; } /** |