From bca1dc3c9adbc5207f3f8eb86918ae6cbcab5a93 Mon Sep 17 00:00:00 2001 From: Deleu Date: Tue, 2 Oct 2018 04:25:31 -0400 Subject: [PATCH] Implementation more complex with better feedback --- src/Illuminate/Container/Container.php | 11 ++++++++++- tests/Container/ContainerTest.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Container/Container.php b/src/Illuminate/Container/Container.php index e3012bfccf94..3e5ede6adc7b 100755 --- a/src/Illuminate/Container/Container.php +++ b/src/Illuminate/Container/Container.php @@ -3,6 +3,7 @@ namespace Illuminate\Container; use Closure; +use Exception; use ArrayAccess; use LogicException; use ReflectionClass; @@ -606,7 +607,15 @@ public function make($abstract, array $parameters = []) */ public function get($id) { - return $this->resolve($id); + try { + return $this->resolve($id); + } catch (Exception $e) { + if ($this->has($id)) { + throw $e; + } + + throw new EntryNotFoundException; + } } /** diff --git a/tests/Container/ContainerTest.php b/tests/Container/ContainerTest.php index d201e5d7de53..2a782d7cfd48 100755 --- a/tests/Container/ContainerTest.php +++ b/tests/Container/ContainerTest.php @@ -1041,7 +1041,7 @@ public function testContainerCanDynamicallySetService() } /** - * @expectedException \Psr\Container\ContainerExceptionInterface + * @expectedException \Illuminate\Container\EntryNotFoundException */ public function testUnknownEntryThrowsException() {