From 678fb09044c87a2f4bf843bb55eb4b057f1c131a Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Mon, 30 Dec 2013 06:06:51 -0800 Subject: exceptions thrown in PHP code can now be caugth and processed by C++ code --- Examples/Exceptions/ExceptionCatch/exception.php | 2 +- Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Examples') diff --git a/Examples/Exceptions/ExceptionCatch/exception.php b/Examples/Exceptions/ExceptionCatch/exception.php index 0fec704..f0bfe90 100644 --- a/Examples/Exceptions/ExceptionCatch/exception.php +++ b/Examples/Exceptions/ExceptionCatch/exception.php @@ -14,4 +14,4 @@ my_catch_exception_function(function($a, $b, $c) { // throw an exception from PHP - the C++ code will catch this exception throw new Exception("Example exception"); -});} +}); diff --git a/Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp b/Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp index a5f7b96..9efdf93 100644 --- a/Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp +++ b/Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp @@ -11,6 +11,7 @@ * Libraries used. */ #include +#include /** * Namespace to use @@ -39,7 +40,8 @@ void my_catch_exception_function(Php::Parameters ¶ms) } catch (Php::Exception &exception) { - // @todo handle the exception that was thrown from PHP space + // handle the exception that was thrown from PHP space + std::cout << "exception caught in CPP code" << std::endl; } } @@ -54,9 +56,7 @@ extern "C" static Php::Extension extension("my_exception_catch","1.0"); // add function to extension - extension.add("my_catch_exception_function", my_catch_exception_function, { - Php::ByVal("callback", Php::callableType); - }); + extension.add("my_catch_exception_function", my_catch_exception_function); // return the extension module return extension.module(); -- cgit v1.2.3