For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > May 2005 > Re: [PEAR] Getting the real file and line from pear errors









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] Getting the real file and line from pear errors
Justin Patrin

2005-05-09, 3:56 am

On 5/8/05, Dan Rossi <pear@electroteque.org> wrote:
> I have still yet to tweak my custom pear error handler, as most the
> time the line and file that it returns in /usr/lib/php/PEAR.php and the
> line of the error method called. Is there a way to get a backtrace of
> two files up, ie my interface class, which composes a pear package
> which then triggers the pear errors, collecting the file and line from
> the pear package and rather than Pear itself. Lemme know.
>=20


Are you using trigger_error? This is really not what you're supposed
to do...it's better to use PEAR_Error objects. As long as you pu the
right error message in your errors you should be able to know where
the problem was.

There is also a backtrace in the PEAR_Error (I think). If there isn't
just call debug_backtrace().

--=20
Justin Patrin
Dan Rossi

2005-05-09, 3:56 am


On 09/05/2005, at 1:34 PM, Justin Patrin wrote:
>
> Are you using trigger_error? This is really not what you're supposed
> to do...


No no noway :)

> it's better to use PEAR_Error objects. As long as you pu the
> right error message in your errors you should be able to know where
> the problem was.


I am pushing the PEAR_Error into Error_Stack then handling it via the
error_stack callback.


>
> There is also a backtrace in the PEAR_Error (I think). If there isn't
> just call debug_backtrace().
>
> --
>


It looks like the backtrace in pear is using debug_backtrace if i
vardump backtrace, its timing out on the screen i am sending the line
and file of the second key of backtrace ie $error->backtrace[1][file] ,
which is getting the pear one, i wonder where the rest of the files are
?
Dan Rossi

2005-05-09, 3:56 am


On 09/05/2005, at 2:20 PM, Justin Patrin wrote:

>
> Well your full backtrace is probably too much for your machine to
> handle. Heavily OO calls make the backtrace very large.
>
> Try looping through the backtrace and just echoing the file / line /
> method keys.
>
> --
> Justin Patrin
>
>


I just did that now tweaked the callback to handle up to 8 traced files
and lines cheers.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com