I'm having problems using "CGI::Carp qw(fatalsToBrowser);" in modperl scripts.

Below are three short scripts and their output under Apache/CGI and Apache/modperl.  All three of them produce (more or less) useful output under Apache/CGI, but only the last one does under Apache/modperl.

The first one calls die() itself. Under Apache/CGI the die() message appears in the web browser (albeit preceded by a spurious Content-Type line), but under Apache/modperl the message goes to the error.log and a bizarre message appears in the web browser consisting of some output from the script, followed by a "200 OK" HTTP header, followed by a message suggesting that all was not OK after all (all the same as if CGI::Carp was not being used).

The second one has a syntax error. Under Apache/CGI a message about a compilation error appears in the web browser (but not the detail of the syntax error itself, which disappears completely - not even going to error.log!); under Apache/modperl an "Internal Server Error" message appears in the web browser (again just like CGI::Carp was not being used) and (curiously) the detail of the syntax error does now at least appear in error.log!

The third one attempts a division by zero and correctly says so in the web browser under both Apache/CGI and Apache/modperl.

Can anybody explain what's going on here???

The first script is closest to the problem I've really got.  I'm using DBI/DBD::mysql and I want SQL syntax errors (which I keep making) to appear in the web browser instead of having to keep opening the error.log.  Running under Apache/CGI I get useful messages like:

Software error:
DBD::mysql::st execute failed: You have an error in your SQL syntax near 'BINARY USER_NAME LIKE 'mk-%' LIMIT 10' at line 1
at d:/inetpub/cgi-bin/mysql.pl line 300.

but under Apache/modperl I just get useless garbage like the error_die.pl below produces.

I'm running Perl 5.005_03 / Apache 1.3.6 / mod_perl 1.22 on NT 4.
 

error_die.pl
------------

    use CGI::Carp qw(fatalsToBrowser);
    $| = 1;
    print "Content-Type: text/html\n\n";
    print "I'm about to die() ...\n";
    die "I'm dead.\n";

Apache/CGI:

I'm about to die() ... Content-type: text/html
Software error:
I'm dead.
For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error.

Apache/modperl:

I'm about to die() ... HTTP/1.1 200 OK Date: Tue, 18 Apr 2000 11:09:35 GMT Server: Apache/1.3.6 (Win32) mod_perl/1.22 Connection: close Content-Type: text/html
OK
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
 

error_syntax.pl
---------------

    use CGI::Carp qw(fatalsToBrowser);
    $| = 1;
    print "Content-Type: text/html\n\n";
    print "Syntax error at the end of this line ...\n"
    print "blah blah blah.\n";

Apache/CGI:

Software error:
Execution of d:/inetpub/cgi-bin/error_syntax.pl aborted due to compilation errors.
For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error.

Apache/modperl:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
 

error_divide.pl
---------------

    use CGI::Carp qw(fatalsToBrowser);
    $| = 1;
    print "Content-Type: text/html\n\n";
    print "I'm about to divide by zero ...\n";
    my $x = 1 / 0;

Apache/CGI:

Software error:
Illegal division by zero at d:/inetpub/cgi-bin/error_divide.pl line 5.
For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error.

Apache/modperl:

Software error:
Illegal division by zero at d:/inetpub/cgi-bin/error_divide.pl line 5.
For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error.
 

Reply via email to