cleanup
This commit is contained in:
@@ -209,6 +209,11 @@ class EnhancedAniWorldLoader(Loader):
|
||||
elif response.status_code == 403:
|
||||
raise NonRetryableError(f"Access forbidden: {url}")
|
||||
elif response.status_code >= 500:
|
||||
# Log suspicious server errors for monitoring
|
||||
self.logger.warning(
|
||||
f"Server error {response.status_code} from {url} "
|
||||
f"- will retry"
|
||||
)
|
||||
raise RetryableError(f"Server error {response.status_code}")
|
||||
else:
|
||||
raise RetryableError(f"HTTP error {response.status_code}")
|
||||
@@ -225,6 +230,18 @@ class EnhancedAniWorldLoader(Loader):
|
||||
|
||||
clean_text = response_text.strip()
|
||||
|
||||
# Quick fail for obviously non-JSON responses
|
||||
if not (clean_text.startswith('[') or clean_text.startswith('{')):
|
||||
# Check if it's HTML error page
|
||||
if clean_text.lower().startswith('<!doctype') or \
|
||||
clean_text.lower().startswith('<html'):
|
||||
raise ValueError("Received HTML instead of JSON")
|
||||
# If doesn't start with JSON markers, likely not JSON
|
||||
self.logger.warning(
|
||||
"Response doesn't start with JSON markers, "
|
||||
"attempting parse anyway"
|
||||
)
|
||||
|
||||
# Attempt increasingly permissive parsing strategies to cope with
|
||||
# upstream anomalies such as HTML escaping, stray BOM markers, and
|
||||
# injected control characters.
|
||||
|
||||
Reference in New Issue
Block a user