There isn't a standard 'fatalsToEmail' pragma for the CGI::Carp module, however it would not be particularly difficult to build such functionality using the set_message method. This method allows a subroutine to be specified which is called with the text of the error message that caused the script to die - For example:
use CGI::Carp qw/ fatalsToBrowser set_message /;
use Mail::Mailer;
BEGIN {
sub fatalsToEmail {
my $error = shift;
my $smtp = Mail::Mailer->new('smtp', Server => '127.0.0.1');
$smtp->open({
'To' => 'you@yourdomain.com',
'From' => 'you@yourdomain.com'
});
print $smtp $error;
$smtp->close;
}
set_message(\&fatalsToEmail);
}
As outlined in the CGI::Carp man page, the set_message routine should be called from within a BEGIN in order to correctly interpret compile-time errors.
| [reply] [d/l] [select] |
| [reply] |
I just tried to visit merlyn's site to read the article, and discovered that WebSense is blocking access to the site. Why, you ask? "Keyword found: stone". Watch out, everyone, Randal's site is apparently drug-related! :-)
(On the other hand, it did classify it as "Entertainment". :-) They got that much right.)
Wally Hartshorn
| [reply] |
Greetings bear,
In addition to the wonderful responses you've already received, I'd add that it would be a good idea to have a fatalsToEmail and fatalsToBrowser routine. In a recent project I've been playing around with, I used the set_message with CGI::Carp fatalsToBrowser to send myself an email and display a "nice" error page to the user. Of course, the "nice" error page tells the user very little other than an apology and some contact information. For a future version, I was thinking about providing the user some sort of automated "summary" information about the particular error. Any such information should be vague enough as to not provide any crackers with any useful information.
Oh, and as I'm sure someone has noted before, always make sure you turn off the "report full text of the error message to browser" feature before you launch go into public enviornment.
gryphon
code('Perl') || die;
| [reply] |