TF-1115 Implement catch exception for StateDataSource

This commit is contained in:
dab246
2022-10-28 12:10:45 +07:00
committed by Dat H. Pham
parent a552b073c1
commit 6a9f36396b
8 changed files with 12 additions and 10 deletions
@@ -85,7 +85,7 @@ class ComposerBindings extends BaseBindings {
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
}
@override
@@ -70,7 +70,7 @@ class DestinationPickerBindings extends BaseBindings {
Get.lazyPut(() => MailboxCacheDataSourceImpl(
Get.find<MailboxCacheManager>(),
Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => EmailDataSourceImpl(
Get.find<EmailAPI>(),
Get.find<RemoteExceptionThrower>()));
@@ -93,7 +93,7 @@ class EmailBindings extends BaseBindings {
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
Get.find<OIDCHttpClient>(),
Get.find<AuthenticationClientBase>(),
@@ -5,12 +5,14 @@ import 'package:tmail_ui_user/features/mailbox/data/datasource/state_datasource.
import 'package:tmail_ui_user/features/mailbox/data/model/state_cache.dart';
import 'package:tmail_ui_user/features/mailbox/data/model/state_type.dart';
import 'package:tmail_ui_user/features/mailbox/data/extensions/state_cache_extension.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
class StateDataSourceImpl extends StateDataSource {
final StateCacheClient _stateCacheClient;
final ExceptionThrower _exceptionThrower;
StateDataSourceImpl(this._stateCacheClient);
StateDataSourceImpl(this._stateCacheClient, this._exceptionThrower);
@override
Future<State?> getState(StateType stateType) {
@@ -18,7 +20,7 @@ class StateDataSourceImpl extends StateDataSource {
final stateCache = await _stateCacheClient.getItem(stateType.value);
return stateCache?.toState();
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
@@ -32,7 +34,7 @@ class StateDataSourceImpl extends StateDataSource {
return await _stateCacheClient.insertItem(stateCache.type.value, stateCache);
}
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
}
@@ -76,7 +76,7 @@ class MailboxBindings extends BaseBindings {
Get.lazyPut(() => MailboxCacheDataSourceImpl(
Get.find<MailboxCacheManager>(),
Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => EmailDataSourceImpl(
Get.find<EmailAPI>(),
Get.find<RemoteExceptionThrower>()));
@@ -158,7 +158,7 @@ class MailboxDashBoardBindings extends BaseBindings {
Get.find<ThreadIsolateWorker>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => MailboxDataSourceImpl(
Get.find<MailboxAPI>(),
Get.find<MailboxIsolateWorker>(),
@@ -55,7 +55,7 @@ class RulesFilterCreatorBindings extends BaseBindings {
Get.lazyPut(() => MailboxCacheDataSourceImpl(
Get.find<MailboxCacheManager>(),
Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
}
@override
@@ -91,7 +91,7 @@ class ThreadBindings extends BaseBindings {
Get.find<ThreadIsolateWorker>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
Get.lazyPut(() => EmailDataSourceImpl(
Get.find<EmailAPI>(),
Get.find<RemoteExceptionThrower>()));