I decided to play with CAP::DebugScreen (since it uses my CAP::ViewCode and I was interested to see what someone is doing with my stuff :) and I have to say that I like it. It's fairly simple and really easy for tracking down fatal errors with a nice stack trace. Overall it's pretty spiffy :) However, I did have some problems getting it to work correctly with my setup. I typically use an ErrorDocument setting in httpd.conf so that all errors are the same throughout a site. However, CAP::DebugScreen only works if fatal errors are thrown and it doesn't add a error_mode() but instead uses the 'error' callback. So while the callback is executed, no error_mode() exists, so C::A simply croaks() and Apache will serve a different doc, not the one generated by CAP::DebugScreen. Attached is a patch that will make CAP::DS add an error_mode during the init phase instead of the error callback. But I was wondering about whether this is the right approach or not. In C::A, the error callback will get executed on errors but it can never trap them. Should this be the case? The callback will only be able to do things like logging, etc. Is this the intent? -- Michael Peters Developer Plus Three, LP
--- /usr/local/lib/perl5/site_perl/5.8.7/CGI/Application/Plugin/DebugScreen.pm 2005-12-21 19:51:00.000000000 -0500
+++ /usr/local/lib/perl5/site_perl/5.8.7/CGI/Application/Plugin/DebugScreen.pm.NEW 2005-12-22 14:03:57.000000000 -0500
@@ -133,6 +133,7 @@
$caller->add_callback( 'init', sub{
my $self = shift;
+ $self->error_mode('__debugscreen_error');
my $de;
$SIG{__DIE__} = sub{
push @{$self->{__stacktrace}},[Devel::StackTrace->new(ignore_package=>[qw/CGI::Application::Plugin::DebugScreen Carp CGI::Carp/])->frames];
@@ -141,20 +142,20 @@
{
no strict 'refs';
*{"$caller\::report"} = \&debug_report;
- }
- });
- $caller->add_callback( 'error', sub{
- my $self = shift;
- if (
- exists $INC{'CGI/Application/Plugin/ViewCode.pm'}
- &&
- ! exists $INC{'CGI/Application/Dispatch.pm'}
- )
- {
- $self->{__viewcode}++;
+ *{"$caller\::__debugscreen_error"} = sub{
+ my $self = shift;
+ if (
+ exists $INC{'CGI/Application/Plugin/ViewCode.pm'}
+ &&
+ ! exists $INC{'CGI/Application/Dispatch.pm'}
+ )
+ {
+ $self->{__viewcode}++;
+ }
+ $self->report(@_);
+ };
}
- $self->report(@_);
});
if ( ! exists $INC{'CGI/Application/Dispatch.pm'} &&
@@ -217,8 +218,7 @@
);
$self->header_props( -type => 'text/html' );
- my $headers = $self->_send_headers();
- print $headers.$t->output;
+ return $t->output;
}
sub print_context {
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.