1 # Poor Man's CGI Module for Perl -- Error Handling
3 # (c) 2002--2012 Martin Mares <mj@ucw.cz>
5 # This software may be freely distributed and used according to the terms
6 # of the GNU Lesser General Public License.
8 package UCW::CGI::ErrorHandler;
10 # E-mail address of the script admin (optional, preferably set in a BEGIN block)
13 # A function called for reporting of errors
16 # Set to true if you want to show detailed error messages to the user
17 our $print_errors = 0;
24 if (!defined $error_reported) {
27 if (defined($error_hook)) {
30 print "Status: 500\n";
31 print "Content-Type: text/plain\n\n";
33 print "Internal bug: ", $_[0], "\n";
35 print "Internal bug.\n";
37 print "Please notify $error_mail\n" if defined $error_mail;
44 $SIG{__DIE__} = sub { report_bug($_[0]); };
45 $SIG{__WARN__} = sub { report_bug("WARNING: " . $_[0]); };