Gunther Birznieks wrote:
> At 02:02 PM 4/18/00 +0100, Steve Hay wrote:
>
> >I'm having problems using "CGI::Carp qw(fatalsToBrowser);" in modperl
> >scripts.
>
> Sorry for the late reply. I was actually trying to figure out why you were
> experiencing this problem. I rarely use Perl 5.005 specific features, and
> so I actually received reasonable results where you were not.
>
> It turns out that CGI::Carp does a specific check for Perl 5.005 and above
> and uses a different mechanism that asks whether it is in an eval block.
> Unfortunately the $^S variable gives information that is not precisely the
> same as the error string parsing (for "eval") technique in it's
> effectiveness under mod_perl.
>
> [snip]
>
> Go into your CGI::Carp.pm file and look for the
> ineval() method. Manually edit it to remove the 5.005 check and just
> compile an ineval() routine that is dependent on longmess() instead of $^S.
Thanks very much for your reply, this works a treat under 5.005_03 and also my
new Perl 5.6.0 / mod_perl 1.23 / Apache 1.3.12 setup which I'm testing out.
This is a great help to me. I hope the change makes it into CGI::Carp -- have
you heard anything from the author yet?
> >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.
>
> This you cannot solve. Although CGI::Carp can catch fatal errors at script
> startup because compile errors are fatal at that point. When a stirng is
> eval'ed to compile the string into a set of data, though, those errors are
> NOT fatal. They are warnings.
>
> Unfortunately, to get around this you would need to modify Apache::Registry
> to trap warnings before compiling code and then die with a fatal error if
> one of those warnings was a compile error.
I can live without this, but it seems like an excellent idea. Any takers for
doing it (I don't think I'm quite up to it myself...)?
- Steve Hay