Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


I have some legacy Perl CGI scripts running under mod_perl.

SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI

When a application level, Database related Software error occurs, raw SQL gets output to the browser. Basically the same message as found in the error_log. (e.g Software error: Can't execute 'SELECT,.. etc)

The access_log does show this as a HTTP 500 error, however setting ErrorDocument within httpd.conf does not catch it)

In the past I have used CGI::Carp qw(fatalsToBrowser) within a script to catch errors and display a custom message, however in this case there are enough scripts that it would be preferred if I could just define a handler or callback somewhere to capture the output and return the output of my choice. (like how Apache can set ErrorDocument)

I thought maybe I could get at through PerlLogHandler or maybe even subclassing RegistryCooker but it looks like that won't work.

Ideas? it seems like a simple thing I am overlooking.

Apache/2.2.3 mod_perl/2.0.5 CentOS release 5.5 (Final)


UPDATE: Turns out I cant use fatalsToBrowser either, currently I'm looking into this: $SIG{__DIE__} Thanks

FINAL UPDATE with solution:

Yes, so the whole point is A. not leaking sensitive details to end users and B. 'save face' in front of customers.
So, the reason why the Apache setting ErrorDocument was not working was because there is also a reverse proxy running. To enable:

ProxyErrorOverride On

Another approach is to write your own PerlResponseHandler (see ModPerl::Registry, basically you subclass ModPerl::RegistryCooker.
my $old_status = $my_rc->{REQ}->status; my $rc = $my_rc->run; if ($rc == 500){ # 500 error occured

In reply to Handle application errors with mod_perl by dvwright

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (4)
    As of 2018-06-23 10:23 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (125 votes). Check out past polls.