fix: Prefer reusing AppBaseException instead of redefining the exception contract CacheException and RemoteException

This commit is contained in:
dab246
2026-03-09 10:27:16 +07:00
committed by Dat H. Pham
parent 236ad5f075
commit 8a21e35d1e
139 changed files with 344 additions and 325 deletions
@@ -11,7 +11,7 @@ import 'package:tmail_ui_user/features/push_notification/data/extensions/firebas
import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart';
import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart';
import 'package:tmail_ui_user/features/push_notification/domain/model/update_token_expired_time_request.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
import 'package:tmail_ui_user/main/exceptions/thrower/exception_thrower.dart';
class CacheFCMDatasourceImpl extends FCMDatasource {
@@ -10,7 +10,7 @@ import 'package:tmail_ui_user/features/push_notification/data/network/fcm_api.da
import 'package:tmail_ui_user/features/push_notification/domain/extensions/firebase_registration_extension.dart';
import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart';
import 'package:tmail_ui_user/features/push_notification/domain/model/update_token_expired_time_request.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
import 'package:tmail_ui_user/main/exceptions/thrower/exception_thrower.dart';
class FcmDatasourceImpl extends FCMDatasource {
@@ -12,7 +12,7 @@ import 'package:tmail_ui_user/features/push_notification/data/datasource/web_soc
import 'package:tmail_ui_user/features/push_notification/data/network/web_socket_api.dart';
import 'package:tmail_ui_user/features/push_notification/domain/exceptions/web_socket_exceptions.dart';
import 'package:tmail_ui_user/main/error/capability_validator.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
import 'package:tmail_ui_user/main/exceptions/thrower/exception_thrower.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
class WebSocketDatasourceImpl implements WebSocketDatasource {
@@ -30,9 +30,9 @@ class FCMCacheManager extends CacheManagerInteraction {
return jmap.State(stateValue);
} else {
if (typeName == TypeName.emailDelivery) {
throw NotFoundEmailDeliveryStateException();
throw const NotFoundEmailDeliveryStateException();
} else {
throw NotFoundStateToRefreshException();
throw const NotFoundStateToRefreshException();
}
}
}
@@ -56,7 +56,7 @@ class FCMCacheManager extends CacheManagerInteraction {
Future<FirebaseRegistrationCache> getStoredFirebaseRegistration() async {
final firebaseRegistration = await _firebaseRegistrationCacheClient.getItem(FirebaseRegistrationCache.keyCacheValue);
if (firebaseRegistration == null) {
throw NotFoundFirebaseRegistrationCacheException();
throw const NotFoundFirebaseRegistrationCacheException();
} else {
return firebaseRegistration;
}
@@ -43,7 +43,7 @@ class FcmApi {
if (matchedFirebaseRegistration?.isNotEmpty == true) {
return matchedFirebaseRegistration!.first;
} else {
throw NotFoundFirebaseRegistrationForDeviceException();
throw const NotFoundFirebaseRegistrationForDeviceException();
}
}
@@ -70,7 +70,7 @@ class FcmApi {
if (firebaseRegistration != null) {
return firebaseRegistration;
} else {
throw NotFoundFirebaseRegistrationCreatedException();
throw const NotFoundFirebaseRegistrationCreatedException();
}
}
@@ -92,7 +92,7 @@ class FcmApi {
if (firebaseRegistrationSetResponse?.destroyed?.contains(registrationId.id) == true) {
return;
} else {
throw NotFoundFirebaseRegistrationDestroyedException();
throw const NotFoundFirebaseRegistrationDestroyedException();
}
}
@@ -119,7 +119,7 @@ class FcmApi {
if (firebaseRegistrationSetResponse?.updated?.containsKey(expiredTimeRequest.firebaseRegistrationId.id) == true) {
return;
} else {
throw NotFoundFirebaseRegistrationUpdatedException();
throw const NotFoundFirebaseRegistrationUpdatedException();
}
}
}
@@ -207,7 +207,7 @@ class FCMRepositoryImpl extends FCMRepository {
if (changesResponse.created?.isNotEmpty == true) {
return _validateMaximumNewEmailsRetrieved(changesResponse.created!);
} else {
throw NotFoundNewReceiveEmailException();
throw const NotFoundNewReceiveEmailException();
}
}