Re: PEAR difficulties

From: Date: Thu, 06 Feb 2003 21:20:39 +0000
Subject: Re: PEAR difficulties
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3638@lists.php.net to get a copy of this message
Right you are... On Thu, 6 Feb 2003, Markus Wolff wrote: > On Thu, 6 Feb 2003 13:45:46 -0600 (CST) > Tony Bibbs <tony@tonybibbs.com> wrote: > > > well, start by finding out what you got back. add this at the top of > > handle_errors: > > > > echo get_class($error); > > exit; > > > > You should get back a PEAR Error object if it is truly an error... > > There´s an easier way. PEAR::DB, like all classes that extend the PEAR > base class, have a built-in method that determines whether an object is > a PEAR_Error object or not, so there´s no need to reinvent the wheel. > > Just rewrite your error handler like this: > > function handle_errors ($error) { > if (DB::isError($error) { > echo($error->getMessage()); > } > } > > If the information you get out of getMessage() is not sufficient, you > can also use toString(), which basically provides a dump of all > properties of the error object. > > Regards, > Markus > > -- ------------------------------------------------------------------------| Tony Bibbs | "I guess you have to remember that those who don't | tony@tonybibbs.com | hunt or fish often see those of us who do as | | harmlessly strange and sort of amusing. When you | | think about it, that might be a fair assessment." | | --Unknown | ------------------------------------------------------------------------|

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