TF-1115 Implement catch exception for CleanupAccountDataSource

This commit is contained in:
dab246
2022-10-28 12:50:23 +07:00
committed by Dat H. Pham
parent ec846d1aa7
commit df2406f752
2 changed files with 10 additions and 5 deletions
@@ -8,6 +8,7 @@ import 'package:tmail_ui_user/features/cleanup/domain/model/recent_login_url_cle
import 'package:tmail_ui_user/features/cleanup/domain/model/recent_login_username_cleanup_rule.dart';
import 'package:tmail_ui_user/features/cleanup/domain/model/recent_search_cleanup_rule.dart';
import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
class CleanupDataSourceImpl extends CleanupDataSource {
@@ -15,12 +16,14 @@ class CleanupDataSourceImpl extends CleanupDataSource {
final RecentSearchCacheManager recentSearchCacheManager;
final RecentLoginUrlCacheManager recentLoginUrlCacheManager;
final RecentLoginUsernameCacheManager recentLoginUsernameCacheManager;
final ExceptionThrower _exceptionThrower;
CleanupDataSourceImpl(
this.emailCacheManager,
this.recentSearchCacheManager,
this.recentLoginUrlCacheManager,
this.recentLoginUsernameCacheManager
this.recentLoginUsernameCacheManager,
this._exceptionThrower
);
@override
@@ -28,7 +31,7 @@ class CleanupDataSourceImpl extends CleanupDataSource {
return Future.sync(() async {
return await emailCacheManager.clean(cleanupRule);
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
@@ -37,7 +40,7 @@ class CleanupDataSourceImpl extends CleanupDataSource {
return Future.sync(() async {
return await recentSearchCacheManager.clean(cleanupRule);
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
@@ -46,7 +49,7 @@ class CleanupDataSourceImpl extends CleanupDataSource {
return Future.sync(() async {
return await recentLoginUrlCacheManager.clean(cleanupRule);
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
@@ -55,7 +58,7 @@ class CleanupDataSourceImpl extends CleanupDataSource {
return Future.sync(() async {
return await recentLoginUsernameCacheManager.clean(cleanupRule);
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
}
@@ -37,6 +37,7 @@ import 'package:tmail_ui_user/features/login/domain/usecases/get_credential_inte
import 'package:tmail_ui_user/features/login/domain/usecases/get_stored_token_oidc_interactor.dart';
import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dart';
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
import 'package:tmail_ui_user/main/utils/email_receive_manager.dart';
class HomeBindings extends BaseBindings {
@@ -74,6 +75,7 @@ class HomeBindings extends BaseBindings {
Get.find<RecentSearchCacheManager>(),
Get.find<RecentLoginUrlCacheManager>(),
Get.find<RecentLoginUsernameCacheManager>(),
Get.find<CacheExceptionThrower>(),
));
Get.lazyPut(() => HiveAccountDatasourceImpl(
Get.find<AccountCacheManager>()