Skip to content

Commit

Permalink
Implementation more complex with better feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
deleugpn committed Oct 2, 2018
1 parent 9da48a0 commit bca1dc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Container;

use Closure;
use Exception;
use ArrayAccess;
use LogicException;
use ReflectionClass;
Expand Down Expand Up @@ -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;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Container/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ public function testContainerCanDynamicallySetService()
}

/**
* @expectedException \Psr\Container\ContainerExceptionInterface
* @expectedException \Illuminate\Container\EntryNotFoundException
*/
public function testUnknownEntryThrowsException()
{
Expand Down

0 comments on commit bca1dc3

Please sign in to comment.