| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- EN-Revision: 24249 -->
- <!-- Reviewed: no -->
- <sect1 id="zend.exception.previous">
- <title>Vorherige Exceptions</title>
- <para>
- Seit Zend Framework 1.10 implementiert <classname>Zend_Exception</classname> die
- Unterstützung von <acronym>PHP</acronym> 5.3 für vorgerige Exceptions. Einfach gesagt, wenn
- man in einem <methodname>catch</methodname> ist, kann man eine neue Exception werfen welche
- auf die vorherige Exception referenziert, was wiederum hilft indem zusätzlicher Kontext
- angeboten wird wenn man debuggt. Indem diese Unterstützung im Zend Framework angeboten wird,
- ist der eigene Code jetzt vorwärts kompatibel mit <acronym>PHP</acronym> 5.3.
- </para>
- <para>
- Vorherige Exceptions werden als drittes Argument an den Contructor der Exceptions indiziert.
- </para>
- <example id="zend.exception.previous.example">
- <title>Vorherige Exceptions</title>
- <programlisting language="php"><![CDATA[
- try {
- $db->query($sql);
- } catch (Zend_Db_Statement_Exception $e) {
- if ($e->getPrevious()) {
- echo '[' . get_class($e)
- . '] hat die vorherige Exception von ['
- . get_class($e->getPrevious())
- . ']' . PHP_EOL;
- } else {
- echo '[' . get_class($e)
- . '] hat keine vorherige Exception'
- . PHP_EOL;
- }
- echo $e;
- // zeigt alle Exceptions beginnend mit der ersten geworfenen
- // Exception wenn vorhanden.
- }
- ]]></programlisting>
- </example>
- </sect1>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|