February 19, 2013
Reporting Error 500 with phpErrorReporter.php
Production websites have become an integral part of business and one can no longer afford not to monitor them actively to detect any errors visitors might be experiencing. Suppose you have something as common as a contact page but which is not working as expected. Under normal conditions the error would be reported to the visitor but not actively to the website owner/operator. A lost contact might mean hundreds of dollars of lost business. The error is reported in the website's Access Log but a month might pass before it is detected if the Access Log is monitored at all. Since errors are relatively few, it's like looking for a needle in a haystack. Active monitoring is required. phpErrorReporter.php
has been installed on my websites since 2011.
fatal errors are reported by email for immediate action while warnings, which go unnoticed by the visitors, are only logged in the error log. The main use of the warnings is to clean up the underlying php code. Fatal errors need immediate action because the visitor received an error page instead of the desired result. The good news is that once the website has been cleaned up there is hardly ever a fatal error to report.
Reporting Error 500
The one missing piece, until now, was implementing Error 500 - Internal Server Error. While this is a rare occurrence it can signal a serious problem such as a bad entry in .htaccess
which causes the website to bomb.
To implement Error 500 reporting requires a custom error page which is enabled in .htaccess:
# custom error pages
ErrorDocument 500 /path/to/error500.php
page calls the error handler if enabled
// if phpErrorReporter enabled
trigger_error("Error 500", E_USER_ERROR);
// else, fall through and do a normal Error 500 page
The rest of html on the custom 500 error page
For complete instructions please see the "read me first" pages. Happy webmastering!
Download The Ultimate Error Reporter
Share this article with your followers