Merge pull request #5390 from matrix-org/erikj/dont_log_on_fail_to_get_file

Don't log exception when failing to fetch remote content.
pull/5478/head
Erik Johnston 2019-06-14 14:25:14 +01:00 committed by GitHub
commit e9344e0dee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

1
changelog.d/5390.bugfix Normal file
View File

@ -0,0 +1 @@
Fix handling of failures fetching remote content to not log failures as exceptions.

View File

@ -17,7 +17,7 @@
import logging
from io import BytesIO
from six import text_type
from six import raise_from, text_type
from six.moves import urllib
import treq
@ -542,10 +542,15 @@ class SimpleHttpClient(object):
length = yield make_deferred_yieldable(
_readBodyToFile(response, output_stream, max_size)
)
except SynapseError:
# This can happen e.g. because the body is too large.
raise
except Exception as e:
logger.exception("Failed to download body")
raise SynapseError(
502, ("Failed to download remote body: %s" % e), Codes.UNKNOWN
raise_from(
SynapseError(
502, ("Failed to download remote body: %s" % e),
),
e
)
defer.returnValue(

View File

@ -386,8 +386,10 @@ class MediaRepository(object):
raise SynapseError(502, "Failed to fetch remote media")
except SynapseError:
logger.exception("Failed to fetch remote media %s/%s",
server_name, media_id)
logger.warn(
"Failed to fetch remote media %s/%s",
server_name, media_id,
)
raise
except NotRetryingDestination:
logger.warn("Not retrying destination %r", server_name)