Melchester Melchester - 4 years ago 130
HTTP Question

How to trap program crashes with HTTP error code 500

I have a number of badly written perl programs serving up my websites. Occasionally they crash and the user sees ...

Software error:
Yadda yadda yadda.
For help, please send mail to the webmaster (webmaster@mywebsite.com), giving this error message and the time and date of the error.


I don't have access to that email address and even if I did those naughty users cannot be trusted to report this error.

So what I would like to do is get this error to trigger a HTTP error 500, so that I can monitor it with a line in the htaccess file like ...

ErrorDocument 500 /fixThisBug.shtml

Answer Source

Thanks to ThisSuitIsBlackNot for the direction.

The perl programs all have

use CGI::Carp(fatalsToBrowser);

Which stifles the HTTP 500 error. Simply removing this will allow the programs to crash "properly".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download