diff options
Diffstat (limited to 'Examples/Exceptions/exception.php')
-rw-r--r-- | Examples/Exceptions/exception.php | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Examples/Exceptions/exception.php b/Examples/Exceptions/exception.php index 9c02286..81bbd50 100644 --- a/Examples/Exceptions/exception.php +++ b/Examples/Exceptions/exception.php @@ -1,25 +1,25 @@ <?php -/* +/** * exception.cpp - * @author Jasper van Eck<jasper.vaneck@copernica.com> * - * An example file to show the working of a function which throws an exception. + * @author Jasper van Eck <jasper.vaneck@copernica.com> + * + * This example shows the working of a C++ function that throws an + * exception, and that exception is then caught by PHP code. * - * Exceptions haven't been implemented yet. - * Therefore this example is not yet a working one. - */ - -/* - * Run a function which throws an exception. */ +// try-catch block to be able to handle the exception try { - echo "Function which throws an exception; my_throw_exception_function()\n"; - echo my_throw_exception_function() . "\n"; + // the my_throw_exception function is implemented in C++. and + // it is going to throw an exception + my_throw_exception_function(); } catch (Exception $exception) { + // the exception object is thrown by C++ code, and caught by PHP + // code echo $exception->getMessage(). "\n"; } |