[HttpKernel][DX] Improve the error message when not defining the controller as a service but using contruct parameters
This commit is contained in:
parent
64eaf7e3a6
commit
c670d5120e
@ -59,7 +59,7 @@ class ContainerControllerResolver extends ControllerResolver
|
||||
$this->throwExceptionIfControllerWasRemoved($class, $e);
|
||||
|
||||
if ($e instanceof \ArgumentCountError) {
|
||||
throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define such a service?', $class), 0, $e);
|
||||
throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class', $class), 0, $e);
|
||||
|
@ -184,16 +184,16 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
$tests[] = [
|
||||
[ControllerTestService::class, 'action'],
|
||||
\InvalidArgumentException::class,
|
||||
'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
|
||||
'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?',
|
||||
];
|
||||
$tests[] = [
|
||||
ControllerTestService::class.'::action',
|
||||
\InvalidArgumentException::class, 'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
|
||||
\InvalidArgumentException::class, 'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?',
|
||||
];
|
||||
$tests[] = [
|
||||
InvokableControllerService::class,
|
||||
\InvalidArgumentException::class,
|
||||
'Controller "Symfony\Component\HttpKernel\Tests\Controller\InvokableControllerService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
|
||||
'Controller "Symfony\Component\HttpKernel\Tests\Controller\InvokableControllerService" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?',
|
||||
];
|
||||
|
||||
return $tests;
|
||||
|
Reference in New Issue
Block a user