Re: common error handling problem - a PFC issue?
| From: | Greg Beaver | Date: | Mon, 28 Jul 2003 01:44:30 +0000 |
| Subject: | Re: common error handling problem - a PFC issue? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-18821@lists.php.net to get a copy of this message | ||
Hi,
I definitely agree that error handling needs a new look - current PEAR error handling is more like exception handling than error handling. Every package should be able to raise warnings and notices without terminating execution in a standard way that allows integrating package error handling as well as package code.
Error codes are used by most packages, in addition to error messages, although a few packages hard-code English messages in the code, which is probably not a great idea.
Perhaps a PEAR_Warning class is in order, and PEAR_Notice class? I would also map the existing PEAR_Error class to PEAR_Exception, so that raiseError returns a PEAR_Exception. PEAR 2.0 could switch over completely, allowing time to switch all PEAR_Error references to PEAR_Exception. I don't think any change to PEAR::isError is needed, as an Exception is an error, and so is an error.
The new classes could publish a mesage to a global repository, perhaps a static class variable (or emulation for php 4). This would allow both realtime display and collection for logging (I obviously have gotten this idea from phpDocumentor :). The cool thing about PEAR is that the CLI could be used to customize display of these warnings/notices for things like the installer, or other applications.
Greg
Matthias Nothhaft wrote:
Hello to all PEAR-Devs, is there a chance to get numeric error codes in all your packages and all your error returns? The error handling of PEAR is a very nice one. But in my projects I need errors that can be processed by my php-scripts. In my Code I can not handle error messages like 'file not found' or 'db connection failed' ! How are you using such error messages? What do you do with them? I do not think that it is a good way to display such error messages! That is not very user friendly... At least not in professional projects! So it would really be great to have numeric error codes in each pear error. That helps extremely to make sure that an application runs in a well controlled way! Did I miss a discussion about that problem? I specially think this must be a need for the PFC !!! regards Matthias