Welcome Guest, Not a member yet? Register   Sign In
Production environment: error page for fatal errors
#4

[eluser]skunkbad[/eluser]
You could create a custom error handler in a hook, using set_error_handler. I use one that emails me the error info.

Code:
<?php
function my_error_handling(){
function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) {
  $message = "An error #" . $e_number . " occurred in script '$e_file' on line $e_line: \n<br />$e_message\n<br />";
  $message .= "Date/Time: " . date('n-j-Y H:i:s') . "\n<br />";
  $message .= "<pre>" . print_r ($e_vars, 1) . "</pre>\n<br />";
  if ( ENVIRONMENT == 'development') {
   echo '<p class="error">' . $message . '</p>';
  }else{
   error_log ($message, 1, ADMIN_EMAIL_ADDRESS );
   if ( ($e_number != E_NOTICE) && ($e_number < 2048)) {
    echo '<p class="error">A system error occurred. We apologize for the inconvenience.</p>';
   }
  }
}
set_error_handler ('my_error_handler',E_ALL^E_NOTICE);
}
/* End of file my_error_handling_hook.php */
/* Location: /application/hooks/my_error_handling_hook.php */

You could easily customize this to display whatever you want to the site visitor.


Messages In This Thread
Production environment: error page for fatal errors - by El Forum - 03-22-2012, 07:52 AM
Production environment: error page for fatal errors - by El Forum - 03-22-2012, 10:22 AM
Production environment: error page for fatal errors - by El Forum - 03-22-2012, 12:56 PM
Production environment: error page for fatal errors - by El Forum - 03-22-2012, 01:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB