Introduce ClassNotFoundException for container
This commit is contained in:
		
							
								
								
									
										16
									
								
								src/Container/ClassNotFoundException.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/Container/ClassNotFoundException.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace Ardent\Undercurrent\Container; | ||||||
|  |  | ||||||
|  | use Exception; | ||||||
|  |  | ||||||
|  | class ClassNotFoundException extends Exception | ||||||
|  | { | ||||||
|  |     public function __construct(string $className) | ||||||
|  |     { | ||||||
|  |         parent::__construct(sprintf( | ||||||
|  |             'Class %s not found in container', | ||||||
|  |             $className | ||||||
|  |         )); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -43,7 +43,7 @@ class GenericContainer implements ContainerInterface | |||||||
|             $className = $this->aliases[$className]; |             $className = $this->aliases[$className]; | ||||||
|         } |         } | ||||||
|         if (!isset($this->definitions[$className])) { |         if (!isset($this->definitions[$className])) { | ||||||
|             throw new Exception("Class $className not found in container"); |             throw new ClassNotFoundException($className); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $definition = $this->definitions[$className]['definition']; |         $definition = $this->definitions[$className]['definition']; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user