Re: Proper error handling with DB_DataObject

From: Date: Thu, 29 Dec 2005 16:12:57 +0000
Subject: Re: Proper error handling with DB_DataObject
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22377@lists.php.net to get a copy of this message
Markus Fischer schrieb:
the documentation somehow lacks the information on how can I test a DB_DataObject if something went terrible wrong? But if update/insert for some reason fails, I'm not sure where my single point is to detect errors.
Put this at some central point in your app: PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errorHandler'); function errorHandler($error) {
    // your handler code here, ex.:
    die($error->getMessage());
} If you're running PHP5, this is even better: PEAR::setErrorHandling(PEAR_ERROR_EXCEPTION); This allows usage of regular try..catch blocks, like this: try {
    $do->insert();
} catch (Exception $ex) {
    error_log("Something wonderful has happened...".$ex);
} CU Markus

« previous php.pear.general (#22377) next »