-
Notifications
You must be signed in to change notification settings - Fork 1
Class for handling multiple errors/exceptions
License
pear2/MultiErrors
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
PEAR2_MultiErrors provides a simple and effective mechanism for aggregating many errors and organizing them by severity. 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. <?php include '/path/to/PEAR2/Autoload.php'; $a = new PEAR2\MultiErrors; $a->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: <?php include '/path/to/PEAR2/Autoload.php'; $a = new PEAR2\MultiErrors; $a->E_ERROR[] = new Exception('message one'); $a->E_ERROR[] = new PEAR2\Blah\Exception('message two'); throw new PEAR2\My\Exception('task failed', $a); ?>
About
Class for handling multiple errors/exceptions
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published