Skip to content

Commit 1646413

Browse files
committed
bug #2023 Fix compatibility to new Symfony FlattenException (alexander-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
2 parents e1f9126 + 1647111 commit 1646413

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Controller/ExceptionController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
use FOS\RestBundle\View\ViewHandlerInterface;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpFoundation\Response;
19-
use Symfony\Component\Debug\Exception\FlattenException;
19+
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
20+
use Symfony\Component\ErrorRenderer\Exception\FlattenException;
2021
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
2122
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
2223

@@ -125,8 +126,14 @@ protected function getStatusCode(\Exception $exception)
125126
*/
126127
private function getTemplateData($currentContent, $code, \Exception $exception, DebugLoggerInterface $logger = null)
127128
{
129+
if (class_exists(FlattenException::class)) {
130+
$exception = FlattenException::createFromThrowable($exception);
131+
} else {
132+
$exception = LegacyFlattenException::create($exception);
133+
}
134+
128135
return [
129-
'exception' => FlattenException::create($exception),
136+
'exception' => $exception,
130137
'status' => 'error',
131138
'status_code' => $code,
132139
'status_text' => array_key_exists($code, Response::$statusTexts) ? Response::$statusTexts[$code] : 'error',

0 commit comments

Comments
 (0)