Wrap additional network errors in factor download

This commit is contained in:
2026-04-07 16:06:54 +08:00
parent 7f0c5de574
commit 71912b8358
2 changed files with 51 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import http.client
import io
import socket
import ssl
@@ -35,7 +36,16 @@ def _download_kf_zip_bytes() -> bytes:
try:
with urlopen(request, timeout=30) as response:
return response.read()
except (URLError, TimeoutError, ConnectionError, socket.timeout, ssl.SSLError) as exc:
except (
URLError,
TimeoutError,
ConnectionError,
socket.timeout,
socket.gaierror,
ssl.SSLError,
http.client.IncompleteRead,
http.client.RemoteDisconnected,
) as exc:
raise ExternalFactorDownloadError(f"Failed to download external factor data: {exc}") from exc