svn: /pear2/Exception/trunk/src/ Exception.php

From: Date: Mon, 22 Feb 2010 00:23:58 +0000
Subject: svn: /pear2/Exception/trunk/src/ Exception.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9189@lists.php.net to get a copy of this message
dufuz Mon, 22 Feb 2010 00:23:58 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=295342 Log: update the example code to be a bit more current. Changed paths: U pear2/Exception/trunk/src/Exception.php Modified: pear2/Exception/trunk/src/Exception.php =================================================================== --- pear2/Exception/trunk/src/Exception.php 2010-02-22 00:22:17 UTC (rev 295341) +++ pear2/Exception/trunk/src/Exception.php 2010-02-22 00:23:58 UTC (rev 295342) @@ -33,27 +33,31 @@ * 2) Usage example * * <code> - * class PEAR2_MyPackage_Exception extends PEAR2_Exception {} - * class Test { + * namespace pear2; + * class PEAR2_MyPackage_Exception extends Exception {} + * + * class Test + * { * function foo() * { - * throw new PEAR2_MyPackage_Exception('Error Message', ERROR_CODE); + * throw new PEAR2_MyPackage_Exception('Error Message', 4); * } - * } + * } * - * function myLogger($pear2_exception) - * { - * echo $pear2_exception->getMessage(); - * } - * // each time a exception is thrown the 'myLogger' will be called - * // (its use is completely optional) - * PEAR2_Exception::addObserver('myLogger'); - * $test = new Test; - * try { + * function myLogger($exception) + * { + * echo 'Logger: ' . $exception->getMessage() . "\n"; + * } + * + * // each time a exception is thrown the 'myLogger' will be called + * // (its use is completely optional) + * Exception::addObserver('\pear2\myLogger'); + * $test = new Test; + * try { * $test->foo(); - * } catch (PEAR2_Exception $e) { + * } catch (\Exception $e) { * print $e; - * } + * } * </code> * * @category pear

« previous php.pear.core (#9189) next »