Commit 39afa6fe authored by Josh Pollock's avatar Josh Pollock
Browse files

use exception interfaces properly

parent 9452a158
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace calderawp\CalderaContainers; namespace calderawp\CalderaContainers;
use calderawp\CalderaContainers\Exceptions\NotFoundException;
use calderawp\CalderaContainers\Interfaces\Arrayable; use calderawp\CalderaContainers\Interfaces\Arrayable;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
...@@ -55,6 +56,7 @@ abstract class Container implements \JsonSerializable, Arrayable, ContainerInter ...@@ -55,6 +56,7 @@ abstract class Container implements \JsonSerializable, Arrayable, ContainerInter
if ($this->has($id)) { if ($this->has($id)) {
return $this->getPimple()->offsetGet($id); return $this->getPimple()->offsetGet($id);
} }
throw new NotFoundException(sprintf('Service %s not found in container', $id));
} }
/** /**
......
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
namespace calderawp\CalderaContainers\Exceptions; namespace calderawp\CalderaContainers\Exceptions;
use Psr\Container\ContainerExceptionInterface;
/** /**
* Class Exception * Class Exception
* *
* Generic Exception - All exceptions from this library MUST be this or a subclass of this. * Generic Exception - All exceptions from this library MUST be this or a subclass of this.
*/ */
class Exception extends \Exception class Exception extends \Exception implements ContainerExceptionInterface
{ {
} }
...@@ -6,11 +6,11 @@ namespace calderawp\CalderaContainers\Exceptions; ...@@ -6,11 +6,11 @@ namespace calderawp\CalderaContainers\Exceptions;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
/** /**
* Class ContainerException * Class NotFoundException
* *
* Exception to throw for ALL container related exceptions. * Exception to throw when container does not contain service
*/ */
class ContainerException extends Exception implements ContainerExceptionInterface class NotFoundException extends Exception implements ContainerExceptionInterface
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment