In article <suppressed>, Steve Comrie wrote:
>> Can you please post an example.
>
> use CGI::Carp qw(fatalsToBrowser set_message);
> BEGIN
> {
> sub handle_errors
> {
> # read error message source and declare local variables
> my $msg = shift;
> $msg =~ s|\n|<br>|gi;
> my $time = localtime(time);
>
> # generate error message page
> my $error = "<html><body style='font: 10px/14px Trebuchet MS, Verdana,
> Arial, sans-serif;'>";
> $error .= '<h2>Error Message</h2><table>';
> $error .= '<tr><td valign=top><b
> style="font-size:11px;">time</b></td><td
> style="font-size:11px;">'.$time.'</td></tr>';
> $error .= '<tr><td valign=top><b
> style="font-size:11px;">message</b></td><td
> style="font-size:11px;">'.$msg.'</td></tr>';
> $error .= '</table>';
> $error .= '<h2>Environment</h2><table>';
> $error .= join('', map { "<tr><td><b
> style='font-size:11px;'>$_</b></td><td
> style='font-size:11px;'>$ENV{$_}</td></tr>" } keys %ENV );
> $error .= '</table>';
> $error .= '</body></html>';
>
> # output the error message to the browser
> print $error;
> }
>
> set_message( \&handle_errors );
> }
This works for the case when you are handling the error from within the
script that is dying. The poster was using Apache to set the handler for
500 errors to a CGI script. In that case you don't have access to the
original environment of the script that died, so something like reading
from a log file is a more attractive solution.
I leave my Error 500 handler turned on the development server, but
don't have it on the production server.
Mark
--
. . . . . . . . . . . . . . . . . . . . . . . . . . .
Mark Stosberg Principal Developer
suppressed Summersault, LLC
765-939-9301 ext 202 database driven websites
. . . . . http://www.summersault.com/ . . . . . . . .
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.