Laravel 7 email exceptions broke after Symfony 5 update

I’ve upgraded to Laravel 7.1 and now with Symfony 5 these classes no longer exist:

use SymfonyComponentDebugExceptionFlattenException;
use SymfonyComponentDebugExceptionHandler as SymfonyExceptionHandler;

I used them in my appExceptionsHandler.php file to send email notifications when exceptions re thrown and they worked well in Laravel 6, but broke when I upgrade from 6.x to 7.1.2 which also upgraded to Symfony 5.

I replaced the aforementioned classes with these:

use SymfonyComponentErrorHandlerErrorRendererHtmlErrorRenderer;
use SymfonyComponentErrorHandlerExceptionFlattenException;

and then replaced this:

$e = FlattenException::create($exception);
$handler = new SymfonyExceptionHandler();
$html = $handler->getHtml($e);

with this:

$e = FlattenException::create($exception);
$handler = new HtmlErrorRenderer();
$content = $handler->getBody($e);

which works, but now instead of getting the debug content in the email like I used to, I instead get a more basic error message as it would be intended for the public.

You can see examples of the different formats here:
https://symfony.com/doc/current/controller/error_pages.html

I’m sure there is something simple I’m missing, but I haven’t yet figured out how to get it to send me the detailed exception data like I used to get prior to the upgrade.

Any suggestions?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *