I upgraded my Laravel app to the latest version Laravel 8. My problem now is that I cannot figure out how to render an exception thrown by the app to html in order to send that html as an email.
My current code (that worked for Laravel 5) to render and send an exception within the App\Exceptions\Handler class:
public function sendEmail(Exception $exception)
{
try {
$e = FlattenException::create($exception);
$handler = new SymfonyExceptionHandler();
$html = $handler->getHtml($e);
$routeName = URL::full();
Mail::send(new ExceptionEmail($html, $routeName));
} catch (Exception $ex) {
if (env("APP_DEBUG") == true) {
dd($ex);
}
}
}
The problem is that class \Symfony\Component\Debug\Exception\FlattenException does not exist anymore in my upgraded app.
What is the appropriate way to render exceptions as html now in Laravel 8?
Thank you very much in advance.