Handle feedgen 429 (#2066)

* Handle feedgen 429

* Translate
This commit is contained in:
Eric Bailey 2023-12-04 15:27:48 -06:00 committed by GitHub
parent 37cafb080b
commit 094a58490f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 40 deletions

View file

@ -25,6 +25,7 @@ export enum KnownError {
FeedgenOffline = 'FeedgenOffline',
FeedgenUnknown = 'FeedgenUnknown',
FeedNSFPublic = 'FeedNSFPublic',
FeedTooManyRequests = 'FeedTooManyRequests',
Unknown = 'Unknown',
}
@ -100,6 +101,9 @@ function FeedgenErrorMessage({
[KnownError.FeedgenUnknown]: _l(
msgLingui`Hmm, some kind of issue occured when contacting the feed server. Please let the feed owner know about this issue.`,
),
[KnownError.FeedTooManyRequests]: _l(
msgLingui`We're sorry, but this feed is currently receiving high traffic and is temporarily unavailable. Please try again later.`,
),
}[knownError]),
[_l, knownError],
)
@ -203,6 +207,13 @@ function detectKnownError(
) {
return KnownError.Block
}
// check status codes
if (error?.status === 429) {
return KnownError.FeedTooManyRequests
}
// convert error to string and continue
if (typeof error !== 'string') {
error = error.toString()
}