[Gas] Re: debugging question

Sigfried Gold sigfried at onthejob.net
Wed Jun 6 10:42:11 CDT 2001


Sorry, my last message was totally wrong -- by the time Gas gets the
error, DBI has already died and doing a stack trace does no good
because we've lost the part of the stack where the offending DBI
call was made.

DBI does use warn() and die(), so using a warn or die handler, as
Zach suggested earlier might be the best way.  i wrote some code
for another project that printed out stack traces.  here's what
that looks like where i ineffectually threw it in my copy of the
gas code:

    if( defined $cgi->param('debug') && $cgi->param('debug') ) {
        print "Content-type: text/html\n\n";
        my $text .= "<FONT COLOR='red'><TABLE BORDER='1'><TR><TD>STACK TRACE</TD></TR>\n";
        my $i = 0;
        my $pk = __PACKAGE__;
        package DB;
        while( my @r = caller($i++) ) {
            $text .= "<TR>\n";
            $text .= join("",map { my $x = $_ || '&nbsp;';"<TD>$x</TD>\n" } @r, @DB::args);
            $text .= "</TR>\n";
        }
        $text .= "</TABLE></FONT>\n";
        print $text;
        package Gas::ErrorManager;
    }

if we tie that code to a die handler, it might work.  i'll try that
later today -- though i don't feel like i understand Gas error handling
and don't know how a die handler would work with what's already in
place.

sigfried



* Sigfried Gold <sigfried at onthejob.net> :
> if you'll notice the error messages:
> 
>    [Tue Jun  5 15:51:55 2001] (Ox1GZYCuz80AAGBqt0Y) eon.cgi: Uncaught Gas
>    Exception: DBD::Pg::db selectrow_array failed: ERROR:  attribute
>    'evaluationform_id' not found
>    Gas::ErrorManager::handle_exception('Gas::ErrorManager=HASH(0x8498014)',
>    'DBD::Pg::db selectrow_array failed: ERROR:  attribute \'evaluati...') called
>    at /home/sgold/public_html/cgi-bin/eon.cgi line 89
> 
> i get one error from DBD and a line number from eon.cgi, where the uncaught
> error handler is called.  it seems that if the uncaught error handler did
> a full stack trace instead of just reporting where it was called from, we'd
> see the more relevant line that spawned the error.
> 
> some of the error handling code seems to do full stack traces -- it may
> just be that uncaught errors don't get that treatment for some reason.
> 
> it's been a while since i did this, but you can user caller() to get the
> entire stack.
> 
> sigfried
> 
> * Zachary C. Miller <wolfgang at wolfgang.groogroo.com> :
> > > Perhaps some caller() output or Carp::cluck()/Carp::confess() output would 
> > > help with a stacktrace?  cluck() might be best because it's what ch1XenZz
> > > d0!!!1
> > 
> > I'm not sure that will help except if it is inserted at the point
> > where the die happens which in this case is in the DBI code. So we'd
> > have to fork off our own version of DBI.  (actually I guess they are
> > warn's not die's). 
> > 
> > I guess maybe we could do something tricky with a __WARN__ handler, or
> > even better just override the warn method (which I guess is what Carp
> > does...we just have to make sure it is properly overridden in the
> > scope of the DBI module. I'll look into this too.
> > 
> > -- 
> > Zachary C. Miller - @= - http://wolfgang.groogroo.com/
> > IMSA 1995 - UIUC 2000 - Just Another Leftist Muppet - Ya Basta!
> >  Social Justice, Community, Nonviolence, Decentralization, Feminism,
> >  Sustainability, Responsibility, Diversity, Democracy, Ecology
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Gas mailing list
> > Gas at lists.groogroo.com
> > http://lists.groogroo.com/cgi-bin/listinfo/gas
> 
> _______________________________________________
> Gas mailing list
> Gas at lists.groogroo.com
> http://lists.groogroo.com/cgi-bin/listinfo/gas




More information about the Gas mailing list