mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-16 21:16:29 +00:00
Catch more httpclient exceptions
This commit is contained in:
parent
9608876783
commit
211cd5964a
1 changed files with 2 additions and 4 deletions
|
@ -2,8 +2,6 @@ import strutils, sequtils, asyncdispatch, httpclient
|
|||
import ../utils, ../prefs
|
||||
export utils, prefs
|
||||
|
||||
from net import SslError
|
||||
|
||||
template cookiePrefs*(): untyped {.dirty.} =
|
||||
getPrefs(request.cookies.getOrDefault("preferences"), cfg)
|
||||
|
||||
|
@ -18,10 +16,10 @@ proc getNames*(name: string): seq[string] =
|
|||
|
||||
proc safeClose*(client: AsyncHttpClient) =
|
||||
try: client.close()
|
||||
except SslError: discard
|
||||
except: discard
|
||||
|
||||
proc safeFetch*(url: string): Future[string] {.async.} =
|
||||
let client = newAsyncHttpClient()
|
||||
try: result = await client.getContent(url)
|
||||
except: discard
|
||||
client.safeClose()
|
||||
finally: client.safeClose()
|
||||
|
|
Loading…
Reference in a new issue