I am trying to build a process that can be used whenever an unexpected error (i.e. database off line, server issues, etc…)
What I would like to do is send a notification to designated people alerting them to the problem and include as much diagnostic or debugging information as possible; and display a message to the end user which apologizes for the inconvenience and letting them know that staff has been notified about this issue.
How can I capture and report the error information in the email?
Currently I have a php file that I bring in via an include (see below) to generate the email message and display the apology message.
<?PHP
unexpected_sys_error(__NAMESPACE__ . ' \ '. __FUNCTION__ . '\\' . __CLASS__, __METHOD__, "error msg holder", __FILE__, __LINE__, debug_print_backtrace());
function unexpected_sys_error($pg_module, $pg_process, $err_message, $err_file, $err_line, $err_backtrace){
$err_msg = 'pg_module: ' . $pg_module . PHP_EOL;
$err_msg .= 'pg_process: ' . $pg_process . PHP_EOL;
$err_msg .= 'err_message: ' . $err_message . PHP_EOL;
$err_msg .= 'err_file: ' . $err_file . PHP_EOL;
$err_msg .= 'err_line: ' . $err_line . PHP_EOL;
$err_msg .= 'err_backtrace: ' . $err_backtrace . PHP_EOL;
mail("[email protected]","DEMO ALERT EMAIL",$err_msg);
}
?>
I am not getting information about the error or the page that is calling the error. When I get the email, I was getting information for the system.unavailable.email.php page not where the issue was occurring.
I am not sure what I am doing wrong. Additionally, I would like to include additional information if possible to help diagnose the error.