[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/system/pear/PEAR/ -> Exception.php (sommaire)

PEAR_Exception PHP versions 4 and 5

Author: Tomas V. V. Cox <cox@idecnet.com>
Author: Hans Lellelid <hans@velum.net>
Author: Bertrand Mansion <bmansion@mamasam.com>
Author: Greg Beaver <cellog@php.net>
Copyright: 1997-2006 The PHP Group
License: http://www.php.net/license/3_0.txt PHP License 3.0
Version: CVS: $Id: Exception.php,v 1.23 2006/01/06 04:47:36 cellog Exp $
Poids: 376 lignes (13 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

PEAR_Exception:: (14 méthodes):
  __construct()
  addObserver()
  removeObserver()
  getUniqueId()
  signal()
  getErrorData()
  getCause()
  getCauseMessage()
  getTraceSafe()
  getErrorClass()
  getErrorMethod()
  __toString()
  toHtml()
  toText()


Classe: PEAR_Exception  - X-Ref

Base PEAR_Exception Class

1) Features:

- Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception))
- Definable triggers, shot when exceptions occur
- Pretty and informative error messages
- Added more context info available (like class, method or cause)
- cause can be a PEAR_Exception or an array of mixed
PEAR_Exceptions/PEAR_ErrorStack warnings
- callbacks for specific exception classes and their children

2) Ideas:

- Maybe a way to define a 'template' for the output

3) Inherited properties from PHP Exception Class:

protected $message
protected $code
protected $line
protected $file
private   $trace

4) Inherited methods from PHP Exception Class:

__clone
__construct
getMessage
getCode
getFile
getLine
getTraceSafe
getTraceSafeAsString
__toString

5) Usage example

<code>
require_once 'PEAR/Exception.php';

class Test {
function foo() {
throw new PEAR_Exception('Error Message', ERROR_CODE);
}
}

function myLogger($pear_exception) {
echo $pear_exception->getMessage();
}
// each time a exception is thrown the 'myLogger' will be called
// (its use is completely optional)
PEAR_Exception::addObserver('myLogger');
$test = new Test;
try {
$test->foo();
} catch (PEAR_Exception $e) {
print $e;
}
</code>

__construct($message, $p2 = null, $p3 = null)   X-Ref
Supported signatures:
PEAR_Exception(string $message);
PEAR_Exception(string $message, int $code);
PEAR_Exception(string $message, Exception $cause);
PEAR_Exception(string $message, Exception $cause, int $code);
PEAR_Exception(string $message, array $causes);
PEAR_Exception(string $message, array $causes, int $code);


addObserver($callback, $label = 'default')   X-Ref

param: mixed $callback  - A valid php callback, see php func is_callable()
param: string $label    The name of the observer. Use this if you want

removeObserver($label = 'default')   X-Ref
Pas de description

getUniqueId()   X-Ref

return: int unique identifier for an observer

signal()   X-Ref
Pas de description

getErrorData()   X-Ref
Return specific error information that can be used for more detailed
error messages or translation.

This method may be overridden in child exception classes in order
to add functionality not present in PEAR_Exception and is a placeholder
to define API

The returned array must be an associative array of parameter => value like so:
<pre>
array('name' => $name, 'context' => array(...))
</pre>
return: array

getCause()   X-Ref
Returns the exception that caused this exception to be thrown

return: Exception|array The context of the exception

getCauseMessage(&$causes)   X-Ref
Function must be public to call on caused exceptions

param: array

getTraceSafe()   X-Ref
Pas de description

getErrorClass()   X-Ref
Pas de description

getErrorMethod()   X-Ref
Pas de description

__toString()   X-Ref
Pas de description

toHtml()   X-Ref
Pas de description

toText()   X-Ref
Pas de description



Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics