Catch more httpclient exceptions

This commit is contained in:
Zed 2020-03-09 00:17:13 +01:00
parent 9608876783
commit 211cd5964a
1 changed files with 2 additions and 4 deletions

View File

@ -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()