<?php

declare(strict_types=1);

namespace App\Domain\AI\Exception;

use App\Domain\AI\AiProvider;
use App\Framework\Exception\ExceptionContext;
use App\Framework\Exception\FrameworkException;

class AiProviderUnavailableException extends FrameworkException
{
    public function __construct(AiProvider $provider, string $reason = '')
    {
        $message = "AI Provider '{$provider->value}' ist nicht verfügbar";
        if ($reason) {
            $message .= ": $reason";
        }

        parent::__construct(
            message: $message,
            context: ExceptionContext::forOperation('ai_provider_connection', 'AI')
                ->withData([
                    'provider' => $provider->value,
                    'reason' => $reason,
                    'unavailable' => true,
                ])
        );
    }
}
