in reply to CGI::Application & mod_perl

What do I have to do to get CGI::Carp (fatalsToBrowser)

With mod_perl you have to write your own __DIE__ and __WARN__ signal handlers to get that to happen
"If you want to redirect this information to the client instead of to error_log you have to take the responsibility yourself, by writing your own exception handler" is from this

Bummer... Apparently the default behavior is to write to the errorlog for any exceptions raised.. so Carp kind of gets ignored..

Whether you're using
PerlModule Apache::PerlRun or PerlModule Apache::Registry
changes your restart behavior.. PerlRun runs normal perl scripts without modification.. probably no restart required.. Registry runs mod_perl which wraps your script and can cause "function redefined" errors .. if plugging in an existing script..

Replies are listed 'Best First'.
Re^2: CGI::Application & mod_perl
by perrin (Chancellor) on Feb 01, 2005 at 03:06 UTC
    If you read a little farther down that page you'll see it says that CGI::Carp does this for you. It should work normally. There may be something about CGI::Application or this person's config that is breaking it.
      Well, exceptions send a 500 to the browser and get logged to the container's errorlog in my mod_perl setup running under either PerlRun or Registry, so without CGI::Application, it's not working for me either now or in the past.. fatalsToBrowser doesn't work out of the box. You still have to write something to handle exceptions and include a reference to it by altering %SIG.

Re^2: CGI::Application & mod_perl
by CountZero (Bishop) on Feb 01, 2005 at 06:53 UTC
    I have CGI::Carp(fatalsToBrowser) in my (test) scripts and it works as expected in a mod_perl setup.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Hmm... and I just convinced myself it couldn't be done. What could I be doing wrong?

      #!/usr/bin/perl + package Apache::mod_test; use CGI::Carp qw(fatalsToBrowser); + sub handler { die 'oops'; } + 1;
      500 error in browser.
      In the error logs I get:
      [Tue Feb 01 09:36:20 2005] [error] [client 192.168.2.3] oops at /usr/l +ib/perl5/5.8.0/CGI/Carp.pm line 314.