Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ServiceNotFoundException.php

function ServiceNotFoundException::__construct

File

vendor/symfony/dependency-injection/Exception/ServiceNotFoundException.php, line 23

Class

ServiceNotFoundException
This exception is thrown when a non-existent service is requested.

Namespace

Symfony\Component\DependencyInjection\Exception

Code

public function __construct(string $id, ?string $sourceId = null, ?\Throwable $previous = null, array $alternatives = [], ?string $msg = null) {
    if (null !== $msg) {
        // no-op
    }
    elseif (null === $sourceId) {
        $msg = \sprintf('You have requested a non-existent service "%s".', $id);
    }
    else {
        $msg = \sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id);
    }
    if ($alternatives) {
        if (1 == \count($alternatives)) {
            $msg .= ' Did you mean this: "';
        }
        else {
            $msg .= ' Did you mean one of these: "';
        }
        $msg .= implode('", "', $alternatives) . '"?';
    }
    parent::__construct($msg, 0, $previous);
}
RSS feed
Powered by Drupal