From b0f7f6fccbfbc2832c1fda42d7e1c861900d24d0 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Thu, 16 Mar 2023 09:33:51 -0400 Subject: [PATCH] have errors for too many requests too --- internal/reddit/client.go | 2 ++ internal/reddit/errors.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/internal/reddit/client.go b/internal/reddit/client.go index 2313c03..582c84c 100644 --- a/internal/reddit/client.go +++ b/internal/reddit/client.go @@ -57,6 +57,7 @@ var ( 401: ErrOauthRevoked, 403: ErrOauthRevoked, 404: ErrSubredditNotFound, + 429: ErrTooManyRequests, } ) @@ -426,6 +427,7 @@ func (rac *AuthenticatedClient) markRateLimited(rli *RateLimitingInfo) error { func (rac *AuthenticatedClient) RefreshTokens(ctx context.Context, opts ...RequestOption) (*RefreshTokenResponse, error) { errmap := map[int]error{ 400: ErrOauthRevoked, + 429: ErrTooManyRequests, } opts = append(rac.client.defaultOpts, opts...) diff --git a/internal/reddit/errors.go b/internal/reddit/errors.go index c1fb179..b3109fe 100644 --- a/internal/reddit/errors.go +++ b/internal/reddit/errors.go @@ -31,4 +31,6 @@ var ( ErrSubredditIsQuarantined = errors.New("subreddit is quarantined") // ErrSubredditNotFound . ErrSubredditNotFound = errors.New("subreddit not found") + // ErrTooManyRequests . + ErrTooManyRequests = errors.New("too many requests") )