cvs: peardoc /en/core/pear/pear-errorstack intro.xml

From: Date: Mon, 24 May 2004 19:48:02 +0000
Subject: cvs: peardoc /en/core/pear/pear-errorstack intro.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-4091@lists.php.net to get a copy of this message
arnaud Mon May 24 15:48:02 2004 EDT Modified files: /peardoc/en/core/pear/pear-errorstack intro.xml Log: * cosmetics * ws http://cvs.php.net/diff.php/peardoc/en/core/pear/pear-errorstack/intro.xml?r1=1.5&r2=1.6&ty=u Index: peardoc/en/core/pear/pear-errorstack/intro.xml diff -u peardoc/en/core/pear/pear-errorstack/intro.xml:1.5 peardoc/en/core/pear/pear-errorstack/intro.xml:1.6 --- peardoc/en/core/pear/pear-errorstack/intro.xml:1.5 Mon May 24 15:42:53 2004 +++ peardoc/en/core/pear/pear-errorstack/intro.xml Mon May 24 15:48:02 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry id="core.pear.pear-errorstack.intro"> <refnamediv> <refname>Introduction to using PEAR_ErrorStack for advanced error handling</refname> @@ -56,7 +56,8 @@ <?php // traditional PEAR_Error usage require_once 'PEAR.php'; -class myobj { +class myobj +{ // there is no way to know where $err comes from function errorCallback($err) { @@ -68,7 +69,7 @@ { error_log($msg, 3, 'somefile.log') } - + function display($msg) { echo $msg . '<br />'; @@ -105,23 +106,24 @@ require_once 'PEAR/ErrorStack.php'; require_once 'Log.php'; define('MYPACKAGE_ERROR_DBERROR', 1); -class myobj { +class myobj +{ var $_stack; function myobj() { $this->_stack = &PEAR_ErrorStack::singleton('MyPackage'); } - + function errorCallback($err) { switch($err['package']){ - case 'MyPackage': - // tell the error stack to log the error only + case 'MyPackage': + // tell the error stack to log the error only // it will not be pushed onto the stack return PEAR_ERRORSTACK_LOG; - break; - case 'InternalDbPackage': - // re-package these errors as a mypackage error fit + break; + case 'InternalDbPackage': + // re-package these errors as a mypackage error fit // for enduser consumption $this->_stack->push(MYPACKAGE_ERROR_DBERROR, 'error', array('dbmessage' => $err['message'], @@ -132,7 +134,7 @@ // tell the internal DB error stack to ignore this error, // as if it never happened return PEAR_ERRORSTACK_IGNORE; - break; + break; } // switch } } @@ -434,15 +436,15 @@ function somecallback($err) { switch($err['code']){ - case ERROR_CODE_ONE: - return PEAR_ERRORSTACK_IGNORE; - break; - case ERROR_CODE_TWO: - return PEAR_ERRORSTACK_PUSH; - break; - case ERROR_CODE_THREE: - return PEAR_ERRORSTACK_LOG; - break; + case ERROR_CODE_ONE: + return PEAR_ERRORSTACK_IGNORE; + break; + case ERROR_CODE_TWO: + return PEAR_ERRORSTACK_PUSH; + break; + case ERROR_CODE_THREE: + return PEAR_ERRORSTACK_LOG; + break; } // switch } $log = &Log::factory('display'); @@ -604,4 +606,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 ---> +--> \ No newline at end of file

« previous php.pear.doc (#4091) next »