Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add original error to log lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Sep 9, 2020
1 parent 89df54a commit b5b96ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions synapse/rest/media/v1/media_repository.py
Expand Up @@ -474,12 +474,13 @@ async def generate_local_exact_thumbnail(

try:
thumbnailer = Thumbnailer(input_path)
except ThumbnailError:
except ThumbnailError as e:
logger.warning(
"Unable to generate a thumbnail for local media %s using a method of %s and type of %s",
"Unable to generate a thumbnail for local media %s using a method of %s and type of %s: %s",
media_id,
t_method,
t_type,
e,
)
return None

Expand Down Expand Up @@ -541,13 +542,14 @@ async def generate_remote_exact_thumbnail(

try:
thumbnailer = Thumbnailer(input_path)
except ThumbnailError:
except ThumbnailError as e:
logger.warning(
"Unable to generate a thumbnail for remote media %s from %s using a method of %s and type of %s",
"Unable to generate a thumbnail for remote media %s from %s using a method of %s and type of %s: %s",
media_id,
server_name,
t_method,
t_type,
e,
)
return None

Expand Down Expand Up @@ -632,12 +634,13 @@ async def _generate_thumbnails(

try:
thumbnailer = Thumbnailer(input_path)
except ThumbnailError:
except ThumbnailError as e:
logger.warning(
"Unable to generate thumbnails for remote media %s from %s using a method of %s and type of %s",
"Unable to generate thumbnails for remote media %s from %s using a method of %s and type of %s: %s",
media_id,
server_name,
media_type,
e,
)
return None

Expand Down
4 changes: 2 additions & 2 deletions synapse/rest/media/v1/thumbnailer.py
Expand Up @@ -42,10 +42,10 @@ class Thumbnailer:
def __init__(self, input_path):
try:
self.image = Image.open(input_path)
except OSError:
except OSError as e:
# If an error occurs opening the image, a thumbnail won't be able to
# be generated.
raise ThumbnailError()
raise ThumbnailError from e

self.width, self.height = self.image.size
self.transpose_method = None
Expand Down

0 comments on commit b5b96ea

Please sign in to comment.