When Grav fires the onFatalException event, I would like to send myself a notice of the error with details. The notification works, but I can't figure out where to grab exception details. Any ideas?
public static function getSubscribedEvents() {
return [
'onPageNotFound' => ['sendAlert', 0],
'onFatalException' => ['sendAlert', 0]
];
}
/**
* Convert error hook into alert mesage
* Route message to alert mechanism (currently Slack)
*
* @param Event $event
* @param string $hook
*/
public function sendAlert(Event $event, $hook) {
$url = $this->slackFriendlyUrl($this->grav['uri']->url);
if ($hook === "onPageNotFound") {
$message = "```404: " . $url . "```";
} elseif ($hook === "onFatalException") {
$message = "@channel: Grav Error ⚠️ ```Fatal Exception:
" . $url . "
" . $exception_string? . "```";
} else {
$message = "@channel: Grav Error ⚠️ ```Undefined Error:
" . $url . "```";
}
$this->slackAlert($message);
}