mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
improved error message for Instance::ensure() when component does not exist (#12967)
fixes #7333
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user