Skip to content

Commit 2ff437a

Browse files
author
Rustem
committed
Add detailed error logging in download_text
Added specific exception handling for HTTPError, URLError, and generic exceptions with detailed error logging to help troubleshoot download failures.
1 parent df0cf77 commit 2ff437a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

textnano/core.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ def download_text(url: str, timeout: int = 30) -> Optional[str]:
6262

6363
return text if text.strip() else None
6464

65-
except Exception:
65+
except urllib.error.HTTPError as e:
66+
logging.error(f"HTTP error {e.code} for {url}: {e.reason}")
67+
return None
68+
except urllib.error.URLError as e:
69+
logging.error(f"URL error for {url}: {e.reason}")
70+
return None
71+
except Exception as e:
72+
logging.error(f"Unexpected error for {url}: {type(e).__name__}: {e}")
6673
return None
6774

6875

0 commit comments

Comments
 (0)