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
|
import ../utils, ../prefs
|
||||||
export utils, prefs
|
export utils, prefs
|
||||||
|
|
||||||
from net import SslError
|
|
||||||
|
|
||||||
template cookiePrefs*(): untyped {.dirty.} =
|
template cookiePrefs*(): untyped {.dirty.} =
|
||||||
getPrefs(request.cookies.getOrDefault("preferences"), cfg)
|
getPrefs(request.cookies.getOrDefault("preferences"), cfg)
|
||||||
|
|
||||||
|
@ -18,10 +16,10 @@ proc getNames*(name: string): seq[string] =
|
||||||
|
|
||||||
proc safeClose*(client: AsyncHttpClient) =
|
proc safeClose*(client: AsyncHttpClient) =
|
||||||
try: client.close()
|
try: client.close()
|
||||||
except SslError: discard
|
except: discard
|
||||||
|
|
||||||
proc safeFetch*(url: string): Future[string] {.async.} =
|
proc safeFetch*(url: string): Future[string] {.async.} =
|
||||||
let client = newAsyncHttpClient()
|
let client = newAsyncHttpClient()
|
||||||
try: result = await client.getContent(url)
|
try: result = await client.getContent(url)
|
||||||
except: discard
|
except: discard
|
||||||
client.safeClose()
|
finally: client.safeClose()
|
||||||
|
|
Loading…
Reference in a new issue