500 would be caused by a cgi error on the web server. You cannot intercept this inline of your PHP code. If its not regular and cannot be replicated, than chances are that its not your PHP code causing it. If you can get specific information including querystring or post input and can then use that to replicate it, that would likely be caused by your code.
This is also not a PHP specific error. 500 is the end all when no other error fits. So effectively its *any* error that has occurred on the webserver. You need to check the error logs for the httpd (and I haven't a clue if cpanel gives you those) in order to determine a cause.
header('HTTP/1.1 420 Enhance Your Calm');