RE: [PEAR] pear error handling
| From: | Dan Rossi | Date: | Mon, 30 Dec 2002 21:40:53 +0000 |
| Subject: | RE: [PEAR] pear error handling | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3112@lists.php.net to get a copy of this message | ||
anyone got a link to an example usage ? there is tonnes of docs on the class
itself but no usage example
http://www.dynamic-webpages.de/php/class.pear.php#example.pear.error1
this
doesnt really tell me what i need to know that i dont
plus here is where i started with the error handling
http://vulcanonet.com/soft/?pack=pear_tut
there is no indication there about setting some userinfo var to give me the
actual line of the error ??
-----Original Message-----
From: Jesus M. Castagnetto [mailto:jcastagnetto@yahoo.com]
Sent: Monday, December 30, 2002 10:01 AM
To: electroteque; pear-general@lists.php.net
Subject: Re: [PEAR] pear error handling
If the $userinfo var was not set then you won't get it back using the
getDebugInfo() method (this is a rephrasing of what I already mentioned
before). See the source code for PEAR and PEAR_Error for more details.
--- electroteque <daniel@electroteque.org> wrote:
> to be less vague here is the output
>
> DB Error: syntax error
> SELECT gallery FROM galleries WHERE galleryID= [nativecode=1064 ** You
have
> an error in your SQL syntax. Check the manual that corresponds to your
MySQL
> server version for the right syntax to use near '' at line 1]
>
>
> "Dan Rossi" <daniel@electroteque.org> wrote in message
> news:EJECKPELDLGDPHHJOEDLOEPJDGAA.daniel@electroteque.org...
> > 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
> >
>
>
>
> --
> 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