From: Sebastian Bergmann Date: Sat, 29 Dec 2001 08:17:57 +0000 (+0000) Subject: Update Exceptions example. X-Git-Tag: PRE_ISSET_PATCH~378 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=76cfd48f729d71d4eea2ca897ea19b3e97c015e4;p=php Update Exceptions example. --- 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.