RE: [PEAR] pear error handling

From: Date: Sun, 29 Dec 2002 10:15:46 +0000
Subject: RE: [PEAR] pear error handling
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3103@lists.php.net to get a copy of this message
i was following the error handling on the pear db page <?php error_reporting (E_ALL ^ E_NOTICE);// this function will handle all errors reported by PHP function php_error_handler ($errno, $errstr, $errfile, $errline) { die ("In $errfile, line: $errline\n<br>$errstr"); } set_error_handler ('php_error_handler');// this function will catch errors generated by Pear,// transform it to PHP errors and trigger them to the php_error_handler function pear_error_handler ($err_obj) { $error_string = $err_obj->getMessage() . '<br>' . $error_obj->getDebugInfo(); trigger_error ($error_string, E_USER_ERROR); } require 'DB.php'; PEAR::setErrorHandling (PEAR_ERROR_CALLBACK, 'pear_error_handler');// force an error $db = DB::connect('pgsql://postgres@localhost/no_db');... ?> -----Original Message----- From: Jesus M. Castagnetto [mailto:jcastagnetto@yahoo.com] Sent: Sunday, December 29, 2002 7:14 PM To: electroteque; pear-general@lists.php.net Subject: Re: [PEAR] pear error handling I think that you might be missing something there. The callback function has to be of a form similar to the one used w/ set_error_handler() (see example there). The method you refer for the PEAR_Error object will not give you back anything you did not put there. See the code for getDebugInfo() in the PEAR_Error class, and you will notice it calls getUserInfo() which returns the $userinfo parameter you passed to the raiseError() method when generating an error object. If I did not understood what you meant, some code or more details might help us help you. --- electroteque <daniel@electroteque.org> wrote: > PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_error'); > > $error_obj->getDebugInfo() , using this does not return the actual line > where the error is > > > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) Research: http://metallo.scripps.edu/ Personal: http://www.castagnetto.org/ __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com

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