1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<?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:
-->
|