Skip to content

Commit

Permalink
bug #2023 Fix compatibility to new Symfony FlattenException (alexande…
Browse files Browse the repository at this point in the history
…r-schranz)

This PR was merged into the 2.6-dev branch.

Discussion
----------

Fix compatibility to new Symfony FlattenException

See https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/ErrorRenderer/Exception/FlattenException.php

Commits
-------

1647111 Fix compatibility to new Symfony FlattenException
  • Loading branch information
xabbuh committed Oct 18, 2019
2 parents e1f9126 + 1647111 commit 1646413
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Controller/ExceptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
use FOS\RestBundle\View\ViewHandlerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;

Expand Down Expand Up @@ -125,8 +126,14 @@ protected function getStatusCode(\Exception $exception)
*/
private function getTemplateData($currentContent, $code, \Exception $exception, DebugLoggerInterface $logger = null)
{
if (class_exists(FlattenException::class)) {
$exception = FlattenException::createFromThrowable($exception);
} else {
$exception = LegacyFlattenException::create($exception);
}

return [
'exception' => FlattenException::create($exception),
'exception' => $exception,
'status' => 'error',
'status_code' => $code,
'status_text' => array_key_exists($code, Response::$statusTexts) ? Response::$statusTexts[$code] : 'error',
Expand Down

0 comments on commit 1646413

Please sign in to comment.