network_handler.py: Use raise_for_status to detect error

This commit is contained in:
Dhinak G
2025-08-27 19:45:50 -04:00
parent 6e4064887c
commit 960376aebb
@@ -65,17 +65,15 @@ class NetworkUtilities:
def validate_link(self) -> bool: def validate_link(self) -> bool:
""" """
Check for 404 error Check for error
Returns: Returns:
bool: True if link is valid, False otherwise bool: True if link is valid, False otherwise
""" """
try: try:
response = SESSION.head(self.url, timeout=5, allow_redirects=True) response = SESSION.head(self.url, timeout=5, allow_redirects=True)
if response.status_code == 404: response.raise_for_status()
return False return True
else:
return True
except ( except (
requests.exceptions.Timeout, requests.exceptions.Timeout,
requests.exceptions.TooManyRedirects, requests.exceptions.TooManyRedirects,