# # cgidie-lib.pl # # This little lib assigns a subroutine to SIG{__DIE__} so when # something wrong happens during the run of your script, you will not # get the ugly "Error Occured" message but a nice html with complete # information: what was the error, where the script was called from # and other parameters, and the most important with email link so user # can easily report to you about it and include all the info you will # ever need to locate the error. # # Also you will not need that custom Cgierror() subroutine people use # everywhere. Just use die() and it'll produce the same thing as you # did with Cgierror() but with no extra coding. # # It also knows to handle the shell vs browser mode. so if you debug # the script from shell you will never see the html around the error # but the sole error message # $SIG{"__DIE__"} = sub { my $error = shift; chomp $error; #$error =~ s/[<&>]/"& #".ord($&).";"/ge; # entity escape $error =~ s/\n/
\n/gs; # return \n as html # this will handle the case when script is run from shell, so # we don't want to see all the HTML but only the error message print $error, return unless defined $ENV{GATEWAY_INTERFACE}; # other parameters my $cgi_url = $ENV{SCRIPT_NAME} || ''; my $referer = $ENV{HTTP_REFERER} || ''; my $remote_user = $ENV{REMOTE_USER} || ''; # OK, report the error print "Content-type: text/html\n\n"; print qq~ Error Occured! $PROJECT_HEADER

An Error Occured!


The errors are:

$error


Additional info:

CGI PATH - $0
CGI URL - $cgi_url
HTTP_REFERER - $referer
REMOTE_USER - $remote_user


Please report it to webadmin

Thanks! ~; exit 0; };