From 76cfd48f729d71d4eea2ca897ea19b3e97c015e4 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sat, 29 Dec 2001 08:17:57 +0000 Subject: [PATCH] Update Exceptions example. --- Zend/ZEND_CHANGES | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/Zend/ZEND_CHANGES b/Zend/ZEND_CHANGES index 57b02ea677..5f399ba4ec 100644 --- a/Zend/ZEND_CHANGES +++ b/Zend/ZEND_CHANGES @@ -47,22 +47,37 @@ Changes in the Zend Engine 2.0 Example - try { - code + error = $_error; + } + + function getException() { + return $this->error; + } + } - if (failure) { - throw new MyException(Failure); + function ThrowException() { + throw new MyException("'This is an exception!'"); } - code - } catch ($exception) { - handle exception + try { + } catch ($exception) { + print "There was an exception: " . $exception->getException(); + print "\n"; + } - throw $exception; // Re-throw exception. - } + try { + ThrowException(); + } catch ($exception) { + print "There was an exception: " . $exception->getException(); + print "\n"; + } + ?> - Old code that does not use exceptions will run without - modifications. + Old code that does not define user-space functions 'catch', + 'throw' and 'try' will run without modifications. * Namespaces. -- 2.40.0