From f01ce77f207e4e6f0e485b434d181e5d84ee3657 Mon Sep 17 00:00:00 2001 From: aidiff-kobe Date: Wed, 11 Mar 2026 12:36:13 +0800 Subject: [PATCH] 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 --- twitter_cli/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/twitter_cli/client.py b/twitter_cli/client.py index b667f78..d1639ed 100644 --- a/twitter_cli/client.py +++ b/twitter_cli/client.py @@ -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