Skip to content

Instantly share code, notes, and snippets.

@thecancerus
Created January 1, 2011 14:25
Show Gist options
  • Save thecancerus/761775 to your computer and use it in GitHub Desktop.
Save thecancerus/761775 to your computer and use it in GitHub Desktop.
<?php
class PHPFatalError {
public function setHandler()
{
register_shutdown_function('handleShutdown');
}
}
function handleShutdown()
{
if (($error = error_get_last())) {
$buffer = ob_get_contents();
ob_clean();
# raport the event, send email etc.
$msg= $buffer;
$um ='We have found some error please try again later.';
ob_start();
$data=array();
$CI = get_instance();
if(!$CI->config->item('DEBUG_PRINT'))
{
$msg='';
}
$data['print_msg'] =$msg;
$data['um'] = $um;
load_page('exception',$data);
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
exit();
# from /error-capture, you can use another redirect, to e.g. home page
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment