Added example and improevd markup

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@278963 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Hannes Magnusson 2009-04-19 11:41:02 +00:00
parent 7305b91c18
commit ddbd2a3f7a

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<refentry xml:id="exception.getprevious" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
@ -14,8 +14,7 @@
<void />
</methodsynopsis>
<para>
Returns previous Exception (the third parameter of <link
linkend="exception.construct">Exception constructor</link>).
Returns previous Exception (the third parameter of <methodname>Exception::__construct</methodname>).
</para>
</refsect1>
@ -31,6 +30,50 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>Exception::getPrevious</methodname> example</title>
<para>
Looping over, and printing out, exception trace.
</para>
<programlisting role="php">
<![CDATA[
<?php
class MyCustomException extends Exception {}
function doStuff() {
try {
throw new InvalidArgumentException("You are doing it wrong!", 112);
} catch(Exception $e) {
throw new MyCustomException("Something happend", 911, $e);
}
}
try {
doStuff();
} catch(Exception $e) {
do {
printf("%s:%d %s (%d) [%s]\n", $e->getFile(), $e->getLine(), $e->getMessage(), $e->getCode(), get_class($e));
} while($e = $e->getPrevious());
}
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
/home/bjori/ex.php:8 Something happend (911) [MyCustomException]
/home/bjori/ex.php:6 You are doing it wrong! (112) [InvalidArgumentException]
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file