<?php

declare(strict_types=1);

namespace App\Framework\Queue\Exceptions;

use App\Framework\Exception\Core\QueueErrorCode;
use App\Framework\Exception\ExceptionContext;

/**
 * Exception thrown when Redis PHP extension is not loaded
 *
 * This is typically caught and handled with graceful fallback to FileQueue.
 */
final class RedisExtensionNotLoadedException extends QueueException
{
    public static function notLoaded(): self
    {
        $context = ExceptionContext::forOperation('queue.init', 'QueueInitializer')
            ->withData([
                'required_extension' => 'redis',
                'loaded_extensions' => get_loaded_extensions(),
                'fallback_available' => 'FileQueue',
            ]);

        return self::fromContext(
            'Redis PHP extension is not loaded',
            $context,
            QueueErrorCode::WORKER_UNAVAILABLE
        );
    }
}
