( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/tmpr/../tmpr/../tmpr/../tmpr/../tmpr/../n8nphp/src/Exceptions/RateLimitException.php
<?php

namespace KayedSpace\N8n\Exceptions;

class RateLimitException extends N8nException
{
    protected int $retryAfter = 0;

    public function setRetryAfter(int $seconds): self
    {
        $this->retryAfter = $seconds;

        return $this;
    }

    public function getRetryAfter(): int
    {
        return $this->retryAfter;
    }

    public static function fromResponse($response, string $message = '', array $context = []): static
    {
        $exception = parent::fromResponse($response, $message ?: 'Rate limit exceeded', $context);

        if ($response->header('Retry-After')) {
            $exception->setRetryAfter((int) $response->header('Retry-After'));
        } elseif ($response->header('X-RateLimit-Reset')) {
            $resetTime = (int) $response->header('X-RateLimit-Reset');
            $exception->setRetryAfter(max(0, $resetTime - time()));
        }

        return $exception;
    }
}