in reply to Re: Re: Re: Trap errors in entire module...
in thread Trap errors in entire module...
I'm trying to have something like the following in place of CGI::Carp but it doesn't work. What's the correct way to do it?
BEGIN { if ($@) { # This print html error code will go into a sub within # the main script. It's here for illustration purposes. print qqContent-type: text/html\n\n~; print qq~<html>\n~; print qq~<head>\n~; print qq~<title>Error</title>\n~; print qq~</head>\n~; print qq~<body>\n~; print qq~A fatal error has occurred blah blah...\n~; print qq~</body>\n~; print qq~</html>~; exit; } }
Found what I was looking for in Carp.pm
use CGI::Carp qw(fatalsToBrowser set_message); BEGIN { sub handle_errors { my $msg = shift; print "<h1>Oh gosh</h1>"; print "<p>Got an error: Not saying much</p>"; } set_message(\&handle_errors); }
|
|---|