utils: add missing warning log on network error (#85742)
gitea/combo/pipeline/head This commit looks good
Details
gitea/combo/pipeline/head This commit looks good
Details
This commit is contained in:
parent
253ae3863b
commit
7aff4544fc
|
@ -26,6 +26,7 @@ from django.utils.http import urlencode
|
|||
from requests import Response
|
||||
from requests import Session as RequestsSession
|
||||
from requests.auth import AuthBase
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from .misc import get_known_service_for_url
|
||||
from .signature import sign_url
|
||||
|
@ -162,7 +163,15 @@ class Requests(RequestsSession):
|
|||
|
||||
if method == 'GET' and cache_duration:
|
||||
cache.set('%s_called' % cache_key, True, cache_duration)
|
||||
response = super().request(method, url, **kwargs)
|
||||
try:
|
||||
response = super().request(method, url, **kwargs)
|
||||
except RequestException as e:
|
||||
if log_errors:
|
||||
extra = {}
|
||||
if django_request:
|
||||
extra['request'] = django_request
|
||||
logging.warning('failed to %s %s (%s)', method, url, e, extra=extra)
|
||||
raise
|
||||
if method == 'GET' and cache_duration:
|
||||
cache.delete('%s_called' % cache_key)
|
||||
if log_errors and (response.status_code // 100 != 2):
|
||||
|
|
Loading…
Reference in New Issue