refactor: Use specific ImportError instead of broad Exception (#10)

Changed the exception handling in _best_chrome_target() to catch
specific ImportError instead of broad Exception. This improves
code clarity and avoids masking unexpected errors.

Also added a debug log message to help diagnose when curl_cffi
is not available.

Co-authored-by: Security Bot <agent@example.com>
This commit is contained in:
aidiff-kobe
2026-03-11 12:36:13 +08:00
committed by GitHub
parent e9efa11fa5
commit f01ce77f20

View File

@@ -76,7 +76,9 @@ def _best_chrome_target():
try:
from curl_cffi.requests import BrowserType
available = {e.value for e in BrowserType}
except Exception:
except ImportError:
# curl_cffi not installed or BrowserType not available
logger.debug("curl_cffi.BrowserType not available, using fallback targets")
available = set()
# Preference order: exact chrome versions, then suffixed variants