Skip to content

Commit

Permalink
Add media proxying error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Sep 1, 2023
1 parent 84dcf49 commit b8fe212
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/routes/media.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit b8fe212

Please sign in to comment.