flutter_cache_manager
flutter_cache_manager copied to clipboard
Add error handling to cache store future operations
:sparkles: What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Bug fix
:arrow_heading_down: What is the current behavior?
When database operations in the retrieveCacheData method encounter exceptions, error callbacks are not properly executed. Specifically:
- When
_getCacheDataFromDatabaseor related async operations throw exceptions, theCompleteris not handled correctly - Exceptions are not caught and propagated, preventing callers from receiving error callbacks
- Entries in
_futureCachemay not be properly cleaned up, causing memory leaks
:new: What is the new behavior (if this is a feature change)?
After the fix:
- Added
catchErrorhandler to properly catch and propagate exceptions to thecompleter - Ensures proper cleanup of
_futureCachein both success and error paths - Callers can now properly receive error callbacks in exception scenarios
:boom: Does this PR introduce a breaking change?
No
:bug: Recommendations for testing
- Simulate database connection exceptions to verify error callbacks are properly executed
- Test scenarios where
_fileExistsmethod throws exceptions - Verify handling when
_cacheInfoRepositoryaccess fails - Confirm that
_futureCacheis properly cleaned up in exception cases
:memo: Links to relevant issues/docs
N/A
:thinking: Checklist before submitting
- [ ] All projects build
- [ ] Follows style guide lines (code style guide)
- [ ] Relevant documentation was updated
- [ ] Rebased onto current develop