summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-12-30 06:06:51 -0800
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-12-30 06:06:51 -0800
commit678fb09044c87a2f4bf843bb55eb4b057f1c131a (patch)
tree31d23b285b4215a1a563b6338e2ac086e07f6736 /Examples
parent00be9c5573d6858c89e2f305b4504b0a477ff230 (diff)
exceptions thrown in PHP code can now be caugth and processed by C++ code
Diffstat (limited to 'Examples')
-rw-r--r--Examples/Exceptions/ExceptionCatch/exception.php2
-rw-r--r--Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp8
2 files changed, 5 insertions, 5 deletions
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 <phpcpp.h>
+#include <iostream>
/**
* Namespace to use
@@ -39,7 +40,8 @@ void my_catch_exception_function(Php::Parameters &params)
}
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();