<?php

declare(strict_types=1);

namespace App\Exceptions;

use App\Services\Evidence\EvidenceResolutionResult;
use RuntimeException;

class ReviewPackEvidenceResolutionException extends RuntimeException
{
    public function __construct(
        public readonly EvidenceResolutionResult $result,
        ?string $message = null,
    ) {
        parent::__construct($message ?? self::defaultMessage($result));
    }

    private static function defaultMessage(EvidenceResolutionResult $result): string
    {
        return match ($result->outcome) {
            'missing_snapshot' => 'No eligible evidence snapshot is available for this review pack.',
            'snapshot_ineligible' => 'The latest evidence snapshot is not eligible for review-pack generation.',
            default => 'Evidence snapshot resolution failed.',
        };
    }
}
