Add media proxying error logging

This commit is contained in:
Zed 2023-09-01 21:37:34 +02:00
parent 84dcf49079
commit b8fe212e94
1 changed files with 2 additions and 0 deletions

View File

@ -37,6 +37,7 @@ proc proxyMedia*(req: jester.Request; url: string): Future[HttpCode] {.async.} =
try:
let res = await client.get(url)
if res.status != "200 OK":
echo "[media] Proxying media failed, status: $1, url: $2, body: $3" % [res.status, url, await res.body]
return Http404
let hashed = $hash(url)
@ -65,6 +66,7 @@ proc proxyMedia*(req: jester.Request; url: string): Future[HttpCode] {.async.} =
await request.client.send(data)
data.setLen 0
except HttpRequestError, ProtocolError, OSError:
echo "[media] Proxying media exception, error: $1, url: $2" % [getCurrentExceptionMsg(), url]
result = Http404
finally:
client.close()