Catch failed guest token exception
This commit is contained in:
parent
23647f1d7f
commit
0924ea033d
|
@ -57,7 +57,11 @@ proc getGuestToken(agent: string; force=false): Future[string] {.async.} =
|
||||||
let headers = genHeaders({"authorization": auth}, agent, base, lang=false)
|
let headers = genHeaders({"authorization": auth}, agent, base, lang=false)
|
||||||
newClient()
|
newClient()
|
||||||
|
|
||||||
let json = parseJson(await client.postContent($(apiBase / tokenUrl)))
|
var res: string
|
||||||
|
try: res = await client.postContent($(apiBase / tokenUrl))
|
||||||
|
except: return
|
||||||
|
|
||||||
|
let json = parseJson(res)
|
||||||
|
|
||||||
if json != nil:
|
if json != nil:
|
||||||
result = json["guest_token"].to(string)
|
result = json["guest_token"].to(string)
|
||||||
|
|
|
@ -31,10 +31,12 @@ proc createMediaRouter*(cfg: Config) =
|
||||||
let client = newAsyncHttpClient()
|
let client = newAsyncHttpClient()
|
||||||
try:
|
try:
|
||||||
await client.downloadFile($uri, filename)
|
await client.downloadFile($uri, filename)
|
||||||
client.safeClose()
|
|
||||||
except HttpRequestError:
|
except HttpRequestError:
|
||||||
|
client.safeClose()
|
||||||
removeFile(filename)
|
removeFile(filename)
|
||||||
resp Http404
|
resp Http404
|
||||||
|
finally:
|
||||||
|
client.safeClose()
|
||||||
|
|
||||||
sendFile(filename)
|
sendFile(filename)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue