cvs: phpdoc /en/language/predefined/exception getprevious.xml

From: Date: Sun, 19 Apr 2009 11:41:02 +0000
Subject: cvs: phpdoc /en/language/predefined/exception getprevious.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-3799@lists.php.net to get a copy of this message
bjori Sun Apr 19 11:41:02 2009 UTC Modified files: /phpdoc/en/language/predefined/exception getprevious.xml Log: Added example and improevd markup http://cvs.php.net/viewvc.cgi/phpdoc/en/language/predefined/exception/getprevious.xml?r1=1.1&r2=1.2&diff_format=u Index: phpdoc/en/language/predefined/exception/getprevious.xml diff -u phpdoc/en/language/predefined/exception/getprevious.xml:1.1 phpdoc/en/language/predefined/exception/getprevious.xml:1.2 --- phpdoc/en/language/predefined/exception/getprevious.xml:1.1 Fri Jan 9 14:04:14 2009 +++ phpdoc/en/language/predefined/exception/getprevious.xml Sun Apr 19 11:41:02 2009 @@ -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

« previous php.doc.cvs (#3799) next »