TF-1115 Implement catch exception for VacationDataSource

This commit is contained in:
dab246
2022-10-28 12:45:06 +07:00
committed by Dat H. Pham
parent d775738b70
commit d0fcad1cac
2 changed files with 10 additions and 4 deletions
@@ -2,18 +2,21 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
import 'package:tmail_ui_user/features/manage_account/data/datasource/vacation_data_source.dart';
import 'package:tmail_ui_user/features/manage_account/data/network/vacation_api.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
class VacationDataSourceImpl extends VacationDataSource {
final VacationAPI _vacationAPI;
VacationDataSourceImpl(this._vacationAPI);
final ExceptionThrower _exceptionThrower;
VacationDataSourceImpl(this._vacationAPI, this._exceptionThrower);
@override
Future<List<VacationResponse>> getAllVacationResponse(AccountId accountId) {
return Future.sync(() async {
return await _vacationAPI.getAllVacationResponse(accountId);
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
@@ -22,7 +25,7 @@ class VacationDataSourceImpl extends VacationDataSource {
return Future.sync(() async {
return await _vacationAPI.updateVacation(accountId, vacationResponse);
}).catchError((error) {
throw error;
_exceptionThrower.throwException(error);
});
}
}