TF-1115 Implement catch exception for HtmlDataSource

This commit is contained in:
dab246
2022-10-28 12:08:08 +07:00
committed by Dat H. Pham
parent d4187eec74
commit 48c1247dfe
5 changed files with 17 additions and 15 deletions
@@ -82,9 +82,9 @@ class ComposerBindings extends BaseBindings {
Get.find<EmailAPI>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => HtmlDataSourceImpl(
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>()
));
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
}
@@ -2,13 +2,15 @@ import 'package:core/core.dart';
import 'package:model/model.dart';
import 'package:tmail_ui_user/features/email/data/datasource/html_datasource.dart';
import 'package:tmail_ui_user/features/email/data/local/html_analyzer.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
class HtmlDataSourceImpl extends HtmlDataSource {
final HtmlAnalyzer _htmlAnalyzer;
final DioClient _dioClient;
final ExceptionThrower _exceptionThrower;
HtmlDataSourceImpl(this._htmlAnalyzer, this._dioClient);
HtmlDataSourceImpl(this._htmlAnalyzer, this._dioClient, this._exceptionThrower);
@override
Future<EmailContent> transformEmailContent(
@@ -18,7 +20,7 @@ class HtmlDataSourceImpl extends HtmlDataSource {
return Future.sync(() async {
return await _htmlAnalyzer.transformEmailContent(emailContent, mapUrlDownloadCID, _dioClient);
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
@@ -27,7 +29,7 @@ class HtmlDataSourceImpl extends HtmlDataSource {
return Future.sync(() async {
return await _htmlAnalyzer.addTooltipWhenHoverOnLink(emailContent);
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
}
@@ -90,9 +90,9 @@ class EmailBindings extends BaseBindings {
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => HiveAccountDatasourceImpl(Get.find<AccountCacheManager>()));
Get.lazyPut(() => HtmlDataSourceImpl(
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>(),
));
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
Get.lazyPut(() => AuthenticationOIDCDataSourceImpl(
Get.find<OIDCHttpClient>(),
@@ -149,9 +149,9 @@ class MailboxDashBoardBindings extends BaseBindings {
Get.find<EmailAPI>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => HtmlDataSourceImpl(
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>()
));
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => SearchDataSourceImpl(Get.find<RecentSearchCacheClient>()));
Get.lazyPut(() => ThreadDataSourceImpl(
Get.find<ThreadAPI>(),
@@ -96,9 +96,9 @@ class ThreadBindings extends BaseBindings {
Get.find<EmailAPI>(),
Get.find<RemoteExceptionThrower>()));
Get.lazyPut(() => HtmlDataSourceImpl(
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>(),
));
Get.find<HtmlAnalyzer>(),
Get.find<DioClient>(),
Get.find<RemoteExceptionThrower>()));
}
@override