Re: exceptions
| From: | Alan Knowles | Date: | Tue, 08 Jun 2004 15:58:20 +0000 |
| Subject: | Re: exceptions | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30181@lists.php.net to get a copy of this message | ||
Wow - nothing like a light read after a hard day removing rootkits :)
I'm not sure how this could be handled with PEAR_ErrorStack, but DataObjects and Flexy have both evolved a user configurable critical error handling mechanism, which theoretically may suit this cunundarum..
* Beginners are going to be totally baffled/annoyed by exceptions.
* Exception purists are going to be fustrated if PEAR doesnt embrace them.
both Flexy & DataObjects use an internal raiseError, with lazy loading of PEAR Error..
eg.
... somewhere in code:
return DB_DataObject::raiseError(
"some message %s",
DB_DATAOBJECT_ERROR_SOMEID,
DB_DATAOBJECT_ERROR_DIE,
.....
);
function raiseError($msg,$id,$howbad)
{
$c = $GLOBALS['_DB_DATAOBJECT']['config']
$hbad = isset($c['error_map'][$howbad]) ?
$c['error_map'][$howbad] : $howbad;
require_once 'PEAR.php';
$r = PEAR::raiseError(.......... 'DB_DataObject_Error');
if ($hb == DB_DATAOBJECT_ERROR_EXCEPTION) {
eval('raise $r;');
}
return $r;
}
While not perfect code, it does illustrate the nature that best practice may be to default returning / dieing, if you want / need exceptions, the library should be capable of 'growing' to suit others needs..
Regards
alan
--
Can you help out?
Need Consulting Services or Know of a Job?
http://www.akbkhome.com