@@ -7,6 +7,7 @@ import experimental/types/common
7
7
const
8
8
rlRemaining = " x-rate-limit-remaining"
9
9
rlReset = " x-rate-limit-reset"
10
+ errorsToSkip = {doesntExist, tweetNotFound, timeout, unauthorized, badRequest}
10
11
11
12
var pool: HttpPool
12
13
@@ -76,14 +77,15 @@ template fetchImpl(result, fetchBody) {.dirty.} =
76
77
77
78
if result .startsWith (" {\" errors" ):
78
79
let errors = result .fromJson (Errors )
79
- echo " Fetch error, API: " , api, " , errors: " , errors
80
- if errors in {expiredToken, badToken, locked}:
81
- invalidate (session)
82
- raise rateLimitError ()
83
- elif errors in {rateLimited}:
84
- # rate limit hit, resets after 24 hours
85
- setLimited (session, api)
86
- raise rateLimitError ()
80
+ if errors notin errorsToSkip:
81
+ echo " Fetch error, API: " , api, " , errors: " , errors
82
+ if errors in {expiredToken, badToken, locked}:
83
+ invalidate (session)
84
+ raise rateLimitError ()
85
+ elif errors in {rateLimited}:
86
+ # rate limit hit, resets after 24 hours
87
+ setLimited (session, api)
88
+ raise rateLimitError ()
87
89
elif result .startsWith (" 429 Too Many Requests" ):
88
90
echo " [sessions] 429 error, API: " , api, " , session: " , session.id
89
91
session.apis[api].remaining = 0
@@ -126,7 +128,7 @@ proc fetch*(url: Uri; api: Api): Future[JsonNode] {.async.} =
126
128
result = newJNull ()
127
129
128
130
let error = result .getError
129
- if error != null:
131
+ if error != null and error notin errorsToSkip :
130
132
echo " Fetch error, API: " , api, " , error: " , error
131
133
if error in {expiredToken, badToken, locked}:
132
134
invalidate (session)
0 commit comments