Zend_Exception-Previous.xml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 24249 -->
  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 <acronym>PHP</acronym> 5.3 für vorgerige Exceptions. Einfach gesagt, wenn
  9. man in einem <methodname>catch</methodname> ist, kann man eine neue Exception werfen welche
  10. auf die vorherige Exception referenziert, was wiederum hilft indem zusätzlicher Kontext
  11. angeboten wird wenn man debuggt. Indem diese Unterstützung im Zend Framework angeboten wird,
  12. ist der eigene Code jetzt vorwärts kompatibel mit <acronym>PHP</acronym> 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. -->