Description
Symfony version(s) affected: 4.4-dev
Description
Want to move discussion from #33918 and #33916 to this issue.
The new ErrorRenderer FlattenException is not compatible with the old Debug FlattenException. And in some places you now get the new FlattenException which crashes current project codes.
How to reproduce
1. Case: Create a custom ExceptionController::showAction
Has symfony/debug
installed:
use Symfony\Component\Debug\Exception\FlattenException;
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null);
This works as expected in 4.3 and in 4.4 you will get an error Symfony\Component\ErrorRenderer\Exception\FlattenException
given but expected Symfony\Component\Debug\Exception\FlattenException
2. Case: FlattenException without Debug installed
In 4.4-dev if a dependency has not debug actually installed the Debug class still exists because of a class_alias in the ErrorRenderer
use Symfony\Component\Debug\Exception\FlattenException;
FlattenException::create(new \Exception(), 200);
This will fail as the new FlattenException doesn't implement create function. If we rename to new from createFromThrowable to create this will the following would fail which is also possible currently:
use Symfony\Component\Debug\Exception\FlattenException;
FlattenException::createFromThrowable(new \Exception(), 200);
So both create and createFromThrowable should be available in 4.4.
Possible Solution
The Symfony\Component\ErrorRenderer\Exception\FlattenException
should extend from the Symfony\Component\Debug\Exception\FlattenException
to keep BC Compatibility in 4.x this can then be removed in 5.0.
Additional Context
I think its a similiar issue we had with the KernelBrowser and the Client here: