1
0
mirror of https://github.com/zedeus/nitter synced 2024-11-29 21:10:09 +01:00

Fix crash on token fetch failure

This commit is contained in:
Zed 2020-06-02 20:37:55 +02:00
parent 7acea6b9e0
commit 3dc85639f4

View File

@ -12,12 +12,17 @@ proc fetchToken(): Future[Token] {.async.} =
"user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0"
})
client = newAsyncHttpClient(headers=headers)
var resp: string
try:
resp = await client.getContent("https://twitter.com")
pos = resp.rfind("gt=")
try: client.close()
except: discard
client.close()
except:
echo "fetching token failed"
return Token()
let pos = resp.rfind("gt=")
if pos == -1:
echo "token parse fail"
return Token()