I’m using the following code to test the outputting of fatal errors to the browser:
use CGI;
use CGI::Carp qw(fatalsToBrowser);
die "test";
I am expecting to see some error in the browser, but there isn’t any, I just get a regular 500 response. I forgot that I had custom error pages on for remote requests, and I now get Script failed to send data..
Also:
> perl -w index.pl
Status: 500
Content-type: text/html
<h1>Software error:</h1>
<pre>test at index.pl line 4.</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.
</p>
[Mon Feb 8 18:29:52 2010] index.pl: test at index.pl line 4.
Try printing a couple of new lines before anything. That signals the end of HTTP headers to the server as the ‘CGI standard’ says. Or you may be able to use something like this: (as copied from the Carp man page):
If that doesn’t work here are a few more tricks:
..And a few more tricks in this Perl Journal article.