fix: Address critical issues from PR review
Fix 4 critical issues identified in code review:
**Error Handling Improvements:**
- Replace bare except blocks with specific exception handlers
- Add logging for TimeoutException and ConnectError
- Prevent silent failures in season loading
- Remove misleading "0 episodes" on error
**Robustness Fixes:**
- Add safe None handling in title comparison (main.py)
Prevents crash when title is None
- Add URL validation before encodeURIComponent (anime.js)
Prevents crash when anime.url is undefined
- Fix unreachable code in retry logic (recommendations.py)
Preserve retry context in exception messages
**Changes:**
- animesama.py: Specific exception handling with print statements
- main.py: Safe None handling with (x.get('title') or '')
- anime.js: URL validation before encoding
- recommendations.py: Better exception messages with retry context
All fixes tested and working correctly.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -46,6 +46,7 @@ class AnimeReleasesFetcher:
|
||||
continue
|
||||
else:
|
||||
logger.error("Jikan API rate limit exceeded after all retries")
|
||||
raise Exception(f"Jikan API rate limit exceeded after {max_retries} retries")
|
||||
|
||||
return response
|
||||
|
||||
@@ -55,9 +56,10 @@ class AnimeReleasesFetcher:
|
||||
logger.warning(f"Request timeout, retrying in {delay}s... (attempt {attempt + 1}/{max_retries})")
|
||||
await asyncio.sleep(delay)
|
||||
else:
|
||||
raise
|
||||
|
||||
raise Exception("Max retries exceeded for Jikan API request")
|
||||
raise Exception(f"Request timeout after {max_retries} retries") from e
|
||||
except Exception as e:
|
||||
# For any other exception, don't retry
|
||||
raise
|
||||
|
||||
async def _get_cached(self, key: str, fetcher):
|
||||
"""Get cached result or fetch new data"""
|
||||
|
||||
Reference in New Issue
Block a user