<?php

namespace App\Services\Forecasting;

use RuntimeException;

final class LeakDetectorException extends RuntimeException
{
    public function __construct(public readonly LeakReport $report)
    {
        $count = count($report->leaks);
        $first = $report->leaks[0] ?? null;
        $sample = $first === null
            ? ''
            : sprintf(' First: feature "%s" reads %s for target %s.', $first['feature'], $first['source_date'], $first['target_monday']);

        parent::__construct(sprintf('Structural time leak detected in %d feature value(s).%s', $count, $sample));
    }
}
