Skip to content

Optimize code and enhance exception safety in repository and UI layers#476

Merged
ProdigyV21 merged 15 commits into
ProdigyV21:mainfrom
Himanth-reddy:chore/combined-pr-coderabbit-fixes
Jul 23, 2026
Merged

Optimize code and enhance exception safety in repository and UI layers#476
ProdigyV21 merged 15 commits into
ProdigyV21:mainfrom
Himanth-reddy:chore/combined-pr-coderabbit-fixes

Conversation

@Himanth-reddy

Copy link
Copy Markdown
Collaborator

This pull request refactors error handling across several repositories to use explicit try/catch blocks instead of runCatching, improves logging for network and HTTP errors, and consolidates regex usage for home server matching. The changes aim to make error handling more robust, ensure proper cancellation propagation, and provide clearer diagnostics.

Error handling improvements:

  • Replaced runCatching with explicit try/catch blocks throughout the codebase for better control over exception handling, ensuring CancellationException is always rethrown and other exceptions are logged appropriately. This affects repositories such as AppUsageAnalyticsRepository, CatalogDiscoveryRepository, CatalogRepository, and HomeServerRepository. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

  • Improved network and HTTP error logging by adding more descriptive log messages, especially in cloud sync and analytics flows, to aid in debugging and monitoring. [1] [2] [3]

Code consistency and maintainability:

  • Centralized all regex usage in HomeServerRepository to the HomeServerRegexes and HomeServerXmlRegexCache utility objects, improving maintainability and consistency. [1] [2] [3] [4] [5] [6]

Minor improvements:

  • Updated header logic to use isNullOrBlank for access tokens, preventing accidental header inclusion of blank tokens.
  • Added missing import android.util.Log where needed. [1] [2]

These changes collectively improve reliability, error visibility, and code clarity.

Himanth-reddy and others added 14 commits July 2, 2026 14:18
### Summary of Changes
- Extracted dynamic regex initializations from inline instantiations to statically cached top-level objects in HomeServerRepository.kt, StreamRepository.kt, PlayerViewModel.kt, and TelegramSearchMatcher.kt to improve performance and avoid GC churn.
- Hardened error handling in TraktRepository.kt by replacing generic runCatching blocks with explicit try-catch blocks that properly handle coroutine cancellations.
- Hardened error handling in HomeServerRepository.kt using proper try-catch.

### Why this improves the codebase
- The performance is improved by eliminating unnecessary regex compilations inside loops.
- Error handling is more robust and prevents coroutine cancellation exceptions from being silently swallowed, avoiding broken structured concurrency state.

### Verification
- [x] Code compiles successfully inside the sandbox environment.
- [x] No new features were added; existing features were fortified and optimized across the modified files.
- [x] Automated tests pass (except for pre-existing unrelated test failures).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@ProdigyV21
ProdigyV21 merged commit 7cd54b7 into ProdigyV21:main Jul 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants