Proper error handling with DB_DataObject
| From: | Markus Fischer | Date: | Thu, 29 Dec 2005 15:45:44 +0000 |
| Subject: | Proper error handling with DB_DataObject | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-22376@lists.php.net to get a copy of this message | ||
Hi,
I'm still not sure how I can do proper error handling in DB_DataObject. I was reading http://pear.php.net/manual/en/package.database.db-dataobject.db-dataobject.raiseerror.php and it says " Default error handling is to create a PEAR::Error, but never return it. If you need to handle errors you should look at setting the PEAR_Error callback this is due to the fact it would wreck havoc on the internal methods!" which doesn't give me a good feeling :) but still the documentation somehow lacks the information on how can I test a DB_DataObject if something went terrible wrong?
When I factory a new object and the table wasn't found, it's quite clear because I get back an error object.
But if update/insert for some reason fails, I'm not sure where my single point is to detect errors.
Is it:
if (PEAR::isError( $ret = $oDoSometable->insert() )) {
// something went wrong
}
or are there other means of quering for errors?
thanks for any pointers,
- Markus