improved error message for Instance::ensure() when component does not exist (#12967)

fixes #7333
This commit is contained in:
Carsten Brandt
2016-11-22 17:49:55 +01:00
committed by GitHub
parent aba42fce4d
commit a837c59182
3 changed files with 28 additions and 3 deletions

View File

@ -128,7 +128,11 @@ class Instance
}
if ($reference instanceof self) {
$component = $reference->get($container);
try {
$component = $reference->get($container);
} catch(\ReflectionException $e) {
throw new InvalidConfigException('Failed to instantiate component or class "' . $reference->id . '".', 0, $e);
}
if ($type === null || $component instanceof $type) {
return $component;
} else {