Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve CompositeContainer error (#274)
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
- Loading branch information
1 parent
b1077f6
commit 3b8ce48
Showing
6 changed files
with
102 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Di; | ||
|
||
use Exception; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
|
||
/** | ||
* CompositeNotFoundException is thrown when no definition or class was found in the composite container for a given ID. | ||
* It contains all exceptions thrown by containers registered in the composite container. | ||
*/ | ||
final class CompositeNotFoundException extends Exception implements NotFoundExceptionInterface | ||
{ | ||
/** | ||
* @param array $exceptions Exceptions of containers in [throwable, container] format. | ||
*/ | ||
public function __construct(array $exceptions) | ||
{ | ||
$message = ''; | ||
|
||
foreach ($exceptions as $i => [$exception, $container]) { | ||
$containerClass = get_class($container); | ||
$containerId = spl_object_id($container); | ||
$number = (int)$i + 1; | ||
|
||
$message .= "\n $number. Container $containerClass #$containerId: {$exception->getMessage()}"; | ||
} | ||
|
||
parent::__construct(sprintf('No definition or class found or resolvable in composite container:%s', $message)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters