Capture "account locked" API error

This commit is contained in:
Zed 2025-02-05 00:35:39 +01:00
parent 1aa9b0dba6
commit 2e13d7b57c
2 changed files with 6 additions and 4 deletions

View file

@ -76,8 +76,8 @@ template fetchImpl(result, fetchBody) {.dirty.} =
if result.startsWith("{\"errors"):
let errors = result.fromJson(Errors)
if errors in {expiredToken, badToken}:
echo "fetch error: ", errors
echo "Fetch error, API: ", api, ", errors: ", errors
if errors in {expiredToken, badToken, locked}:
invalidate(account)
raise rateLimitError()
elif errors in {rateLimited}:
@ -93,6 +93,7 @@ template fetchImpl(result, fetchBody) {.dirty.} =
fetchBody
if resp.status == $Http400:
echo "ERROR 400, ", api, ": ", result
raise newException(InternalError, $url)
except InternalError as e:
raise e
@ -125,8 +126,8 @@ proc fetch*(url: Uri; api: Api): Future[JsonNode] {.async.} =
result = newJNull()
let error = result.getError
if error in {expiredToken, badToken}:
echo "fetchBody error: ", error
echo "Fetch error, API: ", api, ", error: ", error
if error in {expiredToken, badToken, locked}:
invalidate(account)
raise rateLimitError()

View file

@ -57,6 +57,7 @@ type
tweetNotAuthorized = 179
forbidden = 200
badToken = 239
locked = 326
noCsrf = 353
tweetUnavailable = 421
tweetCensored = 422