From e6e30baa43f3d5721fc2b002ddcde4ef8b40ba1c Mon Sep 17 00:00:00 2001 From: PrivacyDev Date: Tue, 18 Apr 2023 22:12:15 -0400 Subject: [PATCH] raise a RateLimitError when Twitter returns HTTP status 429 --- src/apiutils.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/apiutils.nim b/src/apiutils.nim index e45954c..4f35f8d 100644 --- a/src/apiutils.nim +++ b/src/apiutils.nim @@ -76,6 +76,9 @@ template fetchImpl(result, additional_headers, fetchBody) {.dirty.} = if resp.status == "401 Unauthorized" and result.len == 0: getContent() + if resp.status == $Http429: + raise rateLimitError() + if resp.status == $Http503: badClient = true raise newException(InternalError, result)