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.2.0
Convert namespace to PEAR2
Installation
| Status: | 0.2.0 alpha, released on May 23, 2010 |
|---|---|
| License: | New BSD License |
| Maintained: | yes |
Browse Files
6 files in 8 directories.Dependencies for PEAR2_MultiErrors
- PHP ≥ 5.2.0
