Getting the real file and line from pear errors

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting the real file and line from pear errors

Dan Rossi-3
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.

--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply | Threaded
Open this post in threaded view
|

Re: Getting the real file and line from pear errors

Justin Patrin
On 5/8/05, Dan Rossi <[hidden email]> 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.
>

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().

--
Justin Patrin

--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply | Threaded
Open this post in threaded view
|

Re: Getting the real file and line from pear errors

Dan Rossi-3

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
?

--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply | Threaded
Open this post in threaded view
|

Re: Getting the real file and line from pear errors

Justin Patrin
On 5/8/05, Dan Rossi <[hidden email]> wrote:

>
> 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
> ?
>

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

--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply | Threaded
Open this post in threaded view
|

Re: Getting the real file and line from pear errors

Dan Rossi-3

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.

--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php