(I sent this originally to Matt Sergeant, and he suggested i post it here instead)
Apache::Reload a great module, there was however one thing that always drove me crazy. When a module reload failed, I found myself alot of times faced with the "Internal Server Error" page, and then i would have to sludge through the error log.
My proposed patch/addition basically wraps the require code in an eval block, and then if the require fails, it can catch the issue with [EMAIL PROTECTED] It also then replaces the current mod_perl content handler with one that will report the error to the browser. (It does this is a sorta convoluted way by first pushing a PerlFixupHandler which then re-assigns the PerlHandler. This is necessary because (for whatever reason) changes to the PerlHandler done before the URI translation phase will not stick.)
Its a pretty small addition. This is the new code in its entirety, it basically falls in right where "require $module" would go:
## ------------------------------------------------------------------------ - ##
## Code to catch any module reload failures &
## force the error to display in the browser
## ------------------------------------------------------------------------ - ##
eval {
require $key;
warn("Apache::Reload: process $$ reloading $key\n")
if $DEBUG;
};
if ($@) {
my $e = $@;
$r->push_handlers("PerlFixupHandler" => sub {
my $r = shift;
$r->set_handlers("PerlHandler" => [ sub {
my $r = shift;
$r->send_http_header("text/html");
print "<H1>Module Error</H1><HR>" .
"$key failed to load<BR><PRE>$e</PRE>";
}
]);
}
);
warn("Apache::Reload: process $$ failed to reload $key\n") if $DEBUG;
}
## ------------------------------------------------------------------------ - ##
The code is very mod_perl 1.0 specific, the way it does this is probably not ok for mod_perl 2.0 (at least i think not, dont have a mp2 server handy to test it on).
I am not sure if you all think people would be interested in this functionality. It takes a pretty radical approach to error handling by subverting the normal apache content handler. It may not be for everyone.
But you all are interested in it, I can certainly set up and mp2 server (just give me an excuse :) and port this over.
Let me know what you think.
Thanks,
Stevan Little [EMAIL PROTECTED]
p.s. - I apologize for not sending this in the form of a patch, but I am new to the "contributing" end of open source software (after years of "using"). I will get better, I promise.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
