Zend_Exception-Previous.xml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 19777 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="zend.exception.previous">
  5. <title>Vorherige Exceptions</title>
  6. <para>
  7. Seit Zend Framework 1.10 implementiert <classname>Zend_Exception</classname> die
  8. Unterstützung von PHP 5.3 für vorgerige Exceptions. Einfach gesagt, wenn man in einem
  9. <methodname>catch</methodname> ist, kann man eine neue Exception werfen welche auf die
  10. vorherige Exception referenziert, was wiederum hilft indem zusätzlicher Kontext angeboten
  11. wird wenn man debuggt. Indem diese Unterstützung im Zend Framework angeboten wird, ist der
  12. eigene Code jetzt vorwärts kompatibel mit PHP 5.3.
  13. </para>
  14. <para>
  15. Vorherige Exceptions werden als drittes Argument an den Contructor der Exceptions indiziert.
  16. </para>
  17. <example id="zend.exception.previous.example">
  18. <title>Vorherige Exceptions</title>
  19. <programlisting language="php"><![CDATA[
  20. try {
  21. $db->query($sql);
  22. } catch (Zend_Db_Statement_Exception $e) {
  23. if ($e->getPrevious()) {
  24. echo '[' . get_class($e)
  25. . '] hat die vorherige Exception von ['
  26. . get_class($e->getPrevious())
  27. . ']' . PHP_EOL;
  28. } else {
  29. echo '[' . get_class($e)
  30. . '] hat keine vorherige Exception'
  31. . PHP_EOL;
  32. }
  33. echo $e;
  34. // zeigt alle Exceptions beginnend mit der ersten geworfenen
  35. // Exception wenn vorhanden.
  36. }
  37. ]]></programlisting>
  38. </example>
  39. </sect1>
  40. <!--
  41. vim:se ts=4 sw=4 et:
  42. -->