Errors are represented by PHP's built in exception object, and severity levels are represented by PHP's pre-defined error levels E_ERROR, E_WARNING, or E_NOTICE. Adding errors to the PEAR2_MultiErrors object is simple, and done like adding to an array. Retrieving errors can be done with iteration, and count() can be used to determine whether errors were added.

E_ERROR[] = new Exception('message one'); $a->E_WARNING[] = new pear2\Blah\Exception('message two'); // iterate over all errors foreach ($a as $error) {...} // iterate over E_ERROR severity foreach ($a->E_ERROR as $error) {...} count($a); // 2 count($a->E_ERROR); // 1 count($a->E_WARNING); // 1 count(E_NOTICE); // 0 ?>

Used in conjuction with pear2\Exception, it can also be used as a "cause" of an Exception:

E_ERROR[] = new Exception('message one'); $a->E_ERROR[] = new pear2\Blah\Exception('message two'); throw new pear2\My\Exception('task failed', $a); ?>

Release Notes - 0.1.0

Initial Release

Installation

$ php pyrus.phar install PEAR2_MultiErrors-0.1.0
Status: 0.1.0 alpha, released on July 7, 2009
License: New BSD License
Maintained: yes

Browse Files

6 files in 8 directories.

Dependencies for PEAR2_MultiErrors

  • PHP ≥ 5.2.0