good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Handle application errors with mod_perlby dvwright (Initiate) |
on Feb 07, 2013 at 02:31 UTC ( [id://1017544]=perlquestion: print w/replies, xml ) | Need Help?? |
dvwright has asked for the wisdom of the Perl Monks concerning the following question: Howdy, I have some legacy Perl CGI scripts running under mod_perl.
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.
Thanks UPDATE: Turns out I cant use fatalsToBrowser either, currently I'm looking into this: $SIG{__DIE__} Thanks FINAL UPDATE with solution:
Another approach is to write your own PerlResponseHandler (see ModPerl::Registry, basically you subclass ModPerl::RegistryCooker.
Back to
Seekers of Perl Wisdom
|
|