bug #35722 [HttpKernel] Set previous exception when rethrown from controller resolver (danut007ro)

This PR was submitted for the 4.4 branch but it was merged into the 3.4 branch instead.

Discussion
----------

[HttpKernel] Set previous exception when rethrown from controller resolver

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| License       | MIT

If an `\InvalidArgumentException` is catched by ControllerResolver a new one is thrown. The old exception is not added as `previous` parameter on the new one so it is not visible on the exception page. This pull request adds old exception as previous on the new one, so it is also visible on the exception page.

Thank you.

Commits
-------

87d51c1e4b Set previous exception when rethrown from controller resolver
This commit is contained in:
Fabien Potencier 2020-02-15 08:21:47 +01:00
commit 1a51d34d8c

View File

@ -88,7 +88,7 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
try {
$callable = $this->createController($controller);
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $e->getMessage()));
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $e->getMessage()), 0, $e);
}
return $callable;