fix(error-handling): replace bare except clauses with specific exceptions

- qb_downloader.py: catch httpx network errors in logout() and rename_file()
- user.py: log exception details when querying users table fails
- download_client.py: log exception when category creation fails
- title_parser.py: catch specific exceptions (ValueError, AttributeError, TypeError)
  instead of broad Exception in raw_parser()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
EstrellaXD
2026-01-26 14:51:44 +01:00
parent d6e89f62ed
commit 0c8ebb70a3
4 changed files with 61 additions and 26 deletions

View File

@@ -44,7 +44,9 @@ class TitleParser:
@staticmethod
async def tmdb_poster_parser(bangumi: Bangumi):
tmdb_info = await tmdb_parser(bangumi.official_title, settings.rss_parser.language)
tmdb_info = await tmdb_parser(
bangumi.official_title, settings.rss_parser.language
)
if tmdb_info:
logger.debug(f"TMDB Matched, official title is {tmdb_info.title}")
bangumi.poster_link = tmdb_info.poster_link
@@ -98,9 +100,8 @@ class TitleParser:
offset=0,
filter=",".join(settings.rss_parser.filter),
)
except Exception as e:
logger.debug(e)
logger.warning(f"Cannot parse {raw}.")
except (ValueError, AttributeError, TypeError) as e:
logger.warning(f"Cannot parse '{raw}': {type(e).__name__}: {e}")
return None
@staticmethod