From b5b96ea65731f3eb86d5c06b7defd1ab3c23d004 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 9 Sep 2020 07:42:18 -0400 Subject: [PATCH] Add original error to log lines. --- synapse/rest/media/v1/media_repository.py | 15 +++++++++------ synapse/rest/media/v1/thumbnailer.py | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/synapse/rest/media/v1/media_repository.py b/synapse/rest/media/v1/media_repository.py index 20a14a9eea40..69f353d46f9e 100644 --- a/synapse/rest/media/v1/media_repository.py +++ b/synapse/rest/media/v1/media_repository.py @@ -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 @@ -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 @@ -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 diff --git a/synapse/rest/media/v1/thumbnailer.py b/synapse/rest/media/v1/thumbnailer.py index 93dd77e474ea..457ad6031ce2 100644 --- a/synapse/rest/media/v1/thumbnailer.py +++ b/synapse/rest/media/v1/thumbnailer.py @@ -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