Re: PEAR difficulties
| From: | Markus Wolff | Date: | Thu, 06 Feb 2003 20:47:03 +0000 |
| Subject: | Re: PEAR difficulties | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3636@lists.php.net to get a copy of this message | ||
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
--
Markus Wolff <wolff@21st.de>