From ef08949e988f4fd0faaeab2141b9187e7cb7a802 Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 28 Oct 2022 13:00:23 +0700 Subject: [PATCH] TF-1115 Implement catch exception for LoginCacheDataSource --- .../datasource_impl/login_url_datasource_impl.dart | 10 ++++++---- .../login_username_datasource_impl.dart | 11 +++++++---- lib/features/login/presentation/login_bindings.dart | 8 ++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/features/login/data/datasource_impl/login_url_datasource_impl.dart b/lib/features/login/data/datasource_impl/login_url_datasource_impl.dart index f7a1a40aa..b30bb9d20 100644 --- a/lib/features/login/data/datasource_impl/login_url_datasource_impl.dart +++ b/lib/features/login/data/datasource_impl/login_url_datasource_impl.dart @@ -3,12 +3,14 @@ import 'package:tmail_ui_user/features/login/data/datasource/login_url_datasourc import 'package:tmail_ui_user/features/login/data/model/recent_login_url_cache.dart'; import 'package:tmail_ui_user/features/login/domain/extensions/list_recent_login_url_extension.dart'; import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart'; +import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart'; class LoginUrlDataSourceImpl implements LoginUrlDataSource { final RecentLoginUrlCacheClient _recentLoginUrlCacheClient; - - LoginUrlDataSourceImpl(this._recentLoginUrlCacheClient); + final ExceptionThrower _exceptionThrower; + + LoginUrlDataSourceImpl(this._recentLoginUrlCacheClient, this._exceptionThrower); @override Future saveLoginUrl(RecentLoginUrl recentLoginUrl) { @@ -23,7 +25,7 @@ class LoginUrlDataSourceImpl implements LoginUrlDataSource { recentLoginUrl.toRecentLoginUrlCache()); } }).catchError((error) { - throw error; + _exceptionThrower.throwException(error); }); } @@ -45,7 +47,7 @@ class LoginUrlDataSourceImpl implements LoginUrlDataSource { return newListRecentSUrl; }).catchError((error) { - throw error; + _exceptionThrower.throwException(error); }); } diff --git a/lib/features/login/data/datasource_impl/login_username_datasource_impl.dart b/lib/features/login/data/datasource_impl/login_username_datasource_impl.dart index 3afcbb348..d549b3e2f 100644 --- a/lib/features/login/data/datasource_impl/login_username_datasource_impl.dart +++ b/lib/features/login/data/datasource_impl/login_username_datasource_impl.dart @@ -3,11 +3,14 @@ import 'package:tmail_ui_user/features/login/data/datasource/login_username_data import 'package:tmail_ui_user/features/login/data/model/recent_login_username_cache.dart'; import 'package:tmail_ui_user/features/login/domain/extensions/list_recent_login_username_extension.dart'; import 'package:tmail_ui_user/features/login/domain/model/recent_login_username.dart'; +import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart'; class LoginUsernameDataSourceImpl implements LoginUsernameDataSource { - final RecentLoginUsernameCacheClient _recentLoginUsernameCacheClient; - LoginUsernameDataSourceImpl(this._recentLoginUsernameCacheClient); + final RecentLoginUsernameCacheClient _recentLoginUsernameCacheClient; + final ExceptionThrower _exceptionThrower; + + LoginUsernameDataSourceImpl(this._recentLoginUsernameCacheClient, this._exceptionThrower); @override Future> getAllRecentLoginUsernamesLatest({int? limit, String? pattern}) { @@ -26,7 +29,7 @@ class LoginUsernameDataSourceImpl implements LoginUsernameDataSource { ? listValidRecentUsername.sublist(0, newLimit) : listValidRecentUsername; }).catchError((error) { - throw error; + _exceptionThrower.throwException(error); }); } @@ -42,7 +45,7 @@ class LoginUsernameDataSourceImpl implements LoginUsernameDataSource { recentLoginUsername.toRecentLoginUsernameCache()); } }).catchError((error) { - throw error; + _exceptionThrower.throwException(error); }); } diff --git a/lib/features/login/presentation/login_bindings.dart b/lib/features/login/presentation/login_bindings.dart index 18598c5ce..5befc6b2f 100644 --- a/lib/features/login/presentation/login_bindings.dart +++ b/lib/features/login/presentation/login_bindings.dart @@ -102,11 +102,11 @@ class LoginBindings extends BaseBindings { Get.find(), Get.find())); Get.lazyPut(() => LoginUrlDataSourceImpl( - Get.find() - )); + Get.find(), + Get.find())); Get.lazyPut(() => LoginUsernameDataSourceImpl( - Get.find() - )); + Get.find(), + Get.find())); } @override