package Apache2::ASP::ErrorHandler; use strict; use warnings 'all'; use base 'Apache2::ASP::HTTPHandler'; use vars __PACKAGE__->VARS; use MIME::Base64; #============================================================================== sub run { my ($s, $context) = @_; my $error = $Stash->{error}; my $msg = <<"ERROR"; 500 Server Error

500 Server Error

@{[ $error->{title} ]}

File:
@{[ $error->{file} ]}
Line:
@{[ $error->{line} ]}
Time:
@{[ HTTP::Date::time2iso() ]}

Stacktrace follows below:

@{[ $error->{stacktrace} ]}
ERROR $Response->Write( $msg ); $Server->Mail( To => $Config->errors->mail_errors_to, From => $Config->errors->mail_errors_from, Subject => "Apache2::ASP: Error in @{[ $ENV{HTTP_HOST} ]}@{[ $context->r->uri ]}", 'content-type' => 'text/html', 'content-transfer-encoding' => 'base64', Message => encode_base64( $msg ), smtp => $Config->errors->smtp_server, ); }# end run() 1;# return true: =pod =head1 NAME Apache2::ASP::ErrorHandler - Default fatal error handler =head1 SYNOPSIS In your C: ... Apache2::ASP::ErrorHandler you@your-site.com root@localhost localhost ... =head1 DESCRIPTION This class provides a default error handler which does the following: 1) Makes a simple HTML page and prints it to the browser, telling the user that an error has just occurred. 2) Sends that same HTML to the email address specified in the config, using the SMTP server also specified in the config. The email subject will look something like: Apache2::ASP: Error in your-site.com/index.asp =head1 SUBCLASSING To subclass C you must do the following: package My::ErrorHandler; use strict; use warnings 'all'; use base 'Apache2::ASP::ErrorHandler'; use vars __PACKAGE__->VARS; sub run { my ($s, $context) = @_; my $error = $Stash->{error}; # $error looks like this: $VAR1 = { title => 'Cannot call execute with a reference', file => '/tmp/PAGE_CACHE/mysite/index_asp.pm', line => 45, stacktrace => # Output from Carp::confess, }; # Do something here about the error. } 1;# return true: =head1 BUGS It's possible that some bugs have found their way into this release. Use RT L to submit bug reports. =head1 HOMEPAGE Please visit the Apache2::ASP homepage at L to see examples of Apache2::ASP in action. =head1 AUTHOR John Drago =head1 COPYRIGHT Copyright 2008 John Drago. All rights reserved. =head1 LICENSE This software is Free software and is licensed under the same terms as perl itself. =cut