Final Class Yiisoft\Di\BuildingException
| Inheritance | Yiisoft\Di\BuildingException » Exception |
|---|---|
| Implements | Psr\Container\ContainerExceptionInterface, Yiisoft\FriendlyException\FriendlyExceptionInterface |
It wraps all exceptions that don't implement ContainerExceptionInterface during the build process.
Also adds building context for more understanding.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Di\BuildingException | |
| getName() | Yiisoft\Di\BuildingException | |
| getSolution() | Yiisoft\Di\BuildingException |
Method Details
| public __construct( string $id, Throwable $error, string[] $buildStack = [], Throwable|null $previous = null ): mixed | ||
| $id | string |
ID of the definition or name of the class that wasn't found. |
| $error | Throwable | |
| $buildStack | string[] |
Stack of IDs of services requested definition or class that wasn't found. |
| $previous | Throwable|null | |
public function __construct(
private readonly string $id,
Throwable $error,
array $buildStack = [],
?Throwable $previous = null,
) {
$message = sprintf(
'Caught unhandled error "%s" while building "%s".',
$error->getMessage() === '' ? $error::class : $error->getMessage(),
implode('" -> "', $buildStack === [] ? [$id] : $buildStack),
);
parent::__construct($message, 0, $previous);
}
| public getName( ): string |
public function getName(): string
{
return sprintf('Unable to build "%s" object.', $this->id);
}
| public getSolution( ): string|null |
public function getSolution(): ?string
{
$solution = <<<SOLUTION
Ensure that either a service with ID "%1\$s" is defined or such class exists and is autoloadable.
Ensure that configuration for service with ID "%1\$s" is correct.
SOLUTION;
return sprintf($solution, $this->id);
}
Signup or Login in order to comment.