1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.exception.previous">
4 <title>Previous Exceptions</title>
7 Since Zend Framework 1.10, <classname>Zend_Exception</classname> implements the
8 <acronym>PHP</acronym> 5.3 support for previous exceptions. Simply put, when in a
9 <methodname>catch()</methodname> block, you can throw a new exception that references the
10 original exception, which helps provide additional context when debugging. By providing this
11 support in Zend Framework, your code may now be forwards compatible with
12 <acronym>PHP</acronym> 5.3.
16 Previous exceptions are indicated as the third argument to an exception constructor.
19 <example id="zend.exception.previous.example">
20 <title>Previous exceptions</title>
22 <programlisting language="php"><![CDATA[
25 } catch (Zend_Db_Statement_Exception $e) {
26 if ($e->getPrevious()) {
27 echo '[' . get_class($e)
28 . '] has the previous exception of ['
29 . get_class($e->getPrevious())
32 echo '[' . get_class($e)
33 . '] does not have a previous exception'
38 // displays all exceptions starting by the first thrown
39 // exception if available.