<?php

declare(strict_types=1);

namespace Plugin\tnt_mcp\src\Mcp\Action;

/**
 * One thing wrong with one catalog file, addressed precisely enough to fix without searching:
 * file, dotted path (`actions[2].fields[5].enum`) and what was expected. The catalog is
 * hand-written and long, so an error that only says "invalid" costs more than the mistake did.
 */
final class CatalogValidationError
{
    private function __construct(
        public readonly string $file,
        public readonly string $path,
        public readonly string $message,
    ) {
    }

    public static function at(string $file, string $path, string $message): self
    {
        return new self($file, $path, $message);
    }

    /** `<file>: <path>: <message>` — one line, stable, greppable. */
    public function describe(): string
    {
        return \sprintf('%s: %s: %s', $this->file, $this->path === '' ? '<root>' : $this->path, $this->message);
    }
}
