use strict; use CGI::Carp qw/fatalsToBrowser set_message/; BEGIN { sub die_nice { # this will intercept any fatals my $err = shift; print "\n\n

Custom CGI Error

\n"; print "
$err
\n"; print "[script-specific error/dump info goes here]\n"; print "\n\n"; warningsToBrowser(1); } set_message(\&die_nice); } die('[this is the message passed to die]');