[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Re: A bit off topic - CGI:Application and CGI::Carp


> 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 );
}

here's some cut & pasted code for what i'm using on one project now.
obviously you could use an html template to build the error screen, and make
it look pretty, i just wrote this one up quick.


---------------------------------------------------------------------
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.