Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc69b89a

Browse files
committed
feature#19892 [DI] Add corresponding service id in some exception messages (nicolas-grekas)
This PR was merged into the 3.2-dev branch.Discussion----------[DI] Add corresponding service id in some exception messages| Q | A| ------------- | ---| Branch? | master| New feature? | yes| Tests pass? | yes| License | MITThis already helped me figure out where was my mistake :)Commits-------d739f8d [DI] Add corresponding service id in some exception messages
2 parents5129c4c +d739f8d commitc69b89a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
useSymfony\Component\DependencyInjection\Definition;
1515
useSymfony\Component\DependencyInjection\DefinitionDecorator;
1616
useSymfony\Component\DependencyInjection\ContainerBuilder;
17+
useSymfony\Component\DependencyInjection\Exception\ExceptionInterface;
1718
useSymfony\Component\DependencyInjection\Exception\RuntimeException;
1819

1920
/**
@@ -95,9 +96,22 @@ private function resolveArguments(ContainerBuilder $container, array $arguments,
9596
* @throws \RuntimeException When the definition is invalid
9697
*/
9798
privatefunctionresolveDefinition(ContainerBuilder$container,DefinitionDecorator$definition)
99+
{
100+
try {
101+
return$this->doResolveDefinition($container,$definition);
102+
}catch (ExceptionInterface$e) {
103+
$r =new \ReflectionProperty($e,'message');
104+
$r->setAccessible(true);
105+
$r->setValue($e,sprintf('Service "%s": %s',$this->currentId,$e->getMessage()));
106+
107+
throw$e;
108+
}
109+
}
110+
111+
privatefunctiondoResolveDefinition(ContainerBuilder$container,DefinitionDecorator$definition)
98112
{
99113
if (!$container->has($parent =$definition->getParent())) {
100-
thrownewRuntimeException(sprintf('The parentdefinition "%s"defined for definition "%s"does not exist.',$parent,$this->currentId));
114+
thrownewRuntimeException(sprintf('Parentdefinition "%s" does not exist.',$parent));
101115
}
102116

103117
$parentDef =$container->findDefinition($parent);

‎src/Symfony/Component/DependencyInjection/Definition.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getFactory()
9393
publicfunctionsetDecoratedService($id,$renamedId =null,$priority =0)
9494
{
9595
if ($renamedId &&$id ==$renamedId) {
96-
thrownew\InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.',$id));
96+
thrownewInvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.',$id));
9797
}
9898

9999
if (null ===$id) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp