Every exception lives in RoundlyConsulting\HttpClientRateLimits\Exceptions and extends RateLimitException:
| Exception | Thrown when |
|---|---|
RateLimitException | Base class (extends RuntimeException) — catch it to handle every package error. |
RateLimitExceededException | A computed wait exceeds the maxWait() ceiling (the tightest one across a compound limit’s windows). Exposes key, delayMs and maxWaitMs. |
JobReleasedException | The ReleaseDeferrer has released the queued job. Exposes delaySeconds, key and job; the HandlesRateLimitRelease job middleware ends the attempt cleanly. |
InvalidLimitException | A limit allows fewer than one request per window (a rate or maxAttempts below 1). |
UnknownLimiterProfileException | A profile name isn’t defined under limiters. |
InvalidStoreException | The configured store doesn’t implement the Store contract. |
InvalidDeferrerException | The configured deferrer doesn’t implement Deferrer, or releasingJob() / ReleaseDeferrer gets a job without release(). |
InvalidTimespanException | A timespan string — also a profile’s per — isn’t one of second, minute, hour, day. |
UndefinedMethodException | A method called on RateLimit exists on neither Limit nor Limiter. |
Catching everything
use RoundlyConsulting\HttpClientRateLimits\Exceptions\RateLimitException;
try {
Http::rateLimit('github')->get('https://api.github.com/user');
} catch (RateLimitException $e) {
// Any package error: unknown profile, max wait exceeded, invalid store/deferrer, …
report($e);
}In a queued job using the ReleaseDeferrer, a catch-all also catches JobReleasedException — which is fine, as the job has already been released.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.