Fix: handle errors when fetching remote thumbnail and return appropriate status code
This commit is contained in:
parent
3754722126
commit
e6296de3fe
1 changed files with 6 additions and 0 deletions
|
|
@ -71,6 +71,12 @@ async def get_thumbnail(request: Request, config: Config) -> Response:
|
|||
LOG.debug(f"Fetching thumbnail from '{url}'.")
|
||||
response = await client.request(method="GET", url=url, follow_redirects=True)
|
||||
|
||||
if response.status_code != web.HTTPOk.status_code:
|
||||
LOG.error(f"Failed to fetch thumbnail from '{url}'. Status code: {response.status_code}.")
|
||||
return web.json_response(
|
||||
data={"error": "failed to retrieve the thumbnail."}, status=response.status_code
|
||||
)
|
||||
|
||||
return web.Response(
|
||||
body=response.content,
|
||||
headers={
|
||||
|
|
|
|||
Loading…
Reference in a new issue