Skip to content

Improve HTTP timeout message #149

@michaelwood

Description

@michaelwood

We send back a generic server error (500) when we get a file with a timeout issue. Capture this and send back the HTTP error message.

TimeoutError: [Errno 110] Connection timed out
  File "urllib3/connection.py", line 198, in _new_conn
    sock = connection.create_connection(
  File "urllib3/util/connection.py", line 85, in create_connection
    raise err
  File "urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7d9350a229f0>, 'Connection to lrfoundation.org.uk timed out. (connect timeout=None)')
  File "urllib3/connectionpool.py", line 787, in urlopen
    response = self._make_request(
  File "urllib3/connectionpool.py", line 488, in _make_request
    raise new_e
  File "urllib3/connectionpool.py", line 464, in _make_request
    self._validate_conn(conn)
  File "urllib3/connectionpool.py", line 1093, in _validate_conn
    conn.connect()
  File "urllib3/connection.py", line 704, in connect
    self.sock = sock = self._new_conn()
  File "urllib3/connection.py", line 207, in _new_conn
    raise ConnectTimeoutError(
MaxRetryError: HTTPSConnectionPool(host='lrfoundation.org.uk', port=443): Max retries exceeded with url: /sites/default/files/2025-04/lrf_360giving_master_sheet_as_of_16.10.24-2.xlsx (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7d9350a229f0>, 'Connection to lrfoundation.org.uk timed out. (connect timeout=None)'))
  File "requests/adapters.py", line 667, in send
    resp = conn.urlopen(
  File "urllib3/connectionpool.py", line 841, in urlopen
    retries = retries.increment(
  File "urllib3/util/retry.py", line 519, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
ConnectTimeout: HTTPSConnectionPool(host='lrfoundation.org.uk', port=443): Max retries exceeded with url: /sites/default/files/2025-04/lrf_360giving_master_sheet_as_of_16.10.24-2.xlsx (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7d9350a229f0>, 'Connection to lrfoundation.org.uk timed out. (connect timeout=None)'))
  File "cove/input/views.py", line 78, in data_input
    data.download()
  File "cove/input/models.py", line 72, in download
    r = requests.get(
  File "requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "requests/adapters.py", line 688, in send
    raise ConnectTimeout(e, request=request)
TypeError: format requires a mapping
  File "django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/utils/decorators.py", line 134, in _wrapper_view
    response = view_func(request, *args, **kwargs)
  File "cove/input/views.py", line 88, in data_input
    'sub_title': _(
  File "django/utils/functional.py", line 191, in __mod__
    return str(self) % rhs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions