package proposals: Error_Raise and Error_Handler
| From: | Greg Beaver | Date: | Mon, 18 Aug 2003 05:51:42 +0000 |
| Subject: | package proposals: Error_Raise and Error_Handler | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-19948@lists.php.net to get a copy of this message | ||
Hi,
I mentioned the error-handling I've been working on, and now have something concrete to show for it: a fully documented, fully unit-tested pair of packages, Error_Raise and Error_Handler. I am happy to see the improvements of Error_Raise merged with PEAR_Error, if people like what they see, instead of having a separate package as an extension.
Error_Raise
-----------
The problems it solves:
-error codes are not used in PEAR, it requires error codes
-error messages don't preserve data specific to an error message
-only one error level is possible, and this package supports error/warning/notice/exception as error levels
-PEAR_Error is PEAR_Error, determining error origination is impossible without complicated human parsing of a debug_backtrace(). Error_Raise simply sets the packagename and errors can be split up by origination
-context information (file/line number) that is so useful in PHP errors is missing from PEAR_Error
-re-packaging internal errors as errors from the current package is easy through the rePackageError() method (i.e. repackaging a DB error as a CMS error), and the original error is preserved. Nesting is unlimited.
-associating context information with errors is easy (file/line number where the error occurred, or database/query, etc.)
-it's fast: same speed as current PEAR error handling
Error_Handler
-------------
The problems it solves:
-integration of PEAR projects and non-PEAR projects is easy, it can handle errors from both PHP's trigger_error() and PEAR, and even re-package PHP errors as PEAR errors for logging purposes
-logging of errors can be controlled to an extremely intricate level through the optional use of PEAR::Log. Logging by error package is fully supported
-assigning custom error handlers for PEAR errors is easy, and can be done by package
-debugging is made easy: all errors, PHP and PEAR, can be logged in the order in which they occur with full source context information
Error_Handler depends on the added functionality provided by Error_Raise.
Features:
Error_Handler includes a brilliant logger originally designed by Dan Allen, which is designed for use in a graphical HTML browser. Output is un-encumbered by errors, but if any occur, a graphical logo of a bomb appears in the upper right corner of the screen. Click on it, and the error messages are displayed. Greg Militello designed a template based on layers that displays the error messages right over the top of the middle of the window, Dan's pops up a new window with the errors (this is what I used to display the errors in Net_Traceroute when it was proposed).
Error_Raise makes it really easy to create and manipulate errors, and provides all the raw materials needed to handle them. The error message is dynamically generated at runtime, allowing easy internationalization, including display of the error message in completely different ways from the same error object. In addition, information unique to an error message is preserved. For instance, if Archive_Tar finds a corrupt entry in a .tar, the entry name and number could be preserved, allowing automatic processing, and potentially fixing of the error so that no error display is necessary.
Full docs are at http://www.chiaraquartet.net/apidoc, including download links.
pear install http://www.chiaraquartet.net/Error_Raise-0.2.1.tgz
pear install http://www.chiaraquartet.net/Error_Handler-0.2.0.tgz
source code is viewable as part of the documentation.
Regards,
Greg