packages/sql-catalog/src/Core/Extension/UnknownExtensionException.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlCatalog\Core\Extension;
6
7use RuntimeException;
8
9/**
10 * An extension was asked for by a name nothing is registered under.
11 *
12 * @visibility root
13 */
14final class UnknownExtensionException extends RuntimeException
15{
16    /**
17     * @param string $name The name that was asked for
18     * @param list<string> $available The names that are registered
19     */
20    public function __construct(
21        public readonly string $name,
22        public readonly array $available,
23    ) {
24        parent::__construct(sprintf(
25            'Unknown extension "%s". Available extensions: %s.',
26            $name,
27            $available === [] ? 'none' : implode(', ', $available),
28        ));
29    }
30}
31