mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
7305b91c18
commit
ddbd2a3f7a
1 changed files with 46 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue