TF-1361 Fix open notification while no network connection

This commit is contained in:
dab246
2023-01-04 09:43:39 +07:00
committed by Dat H. Pham
parent f2636b1ecf
commit e8a8676d37
4 changed files with 65 additions and 10 deletions
@@ -5,6 +5,7 @@ import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.da
abstract class RemoteException with EquatableMixin implements Exception {
static const connectError = 'Connect error';
static const noNetworkError = 'No network error';
final String? message;
final int? code;
@@ -40,4 +41,11 @@ class MethodLevelErrors extends RemoteException {
class CannotCalculateChangesMethodResponseException extends MethodLevelErrors {
CannotCalculateChangesMethodResponseException({String? message}) : super(ErrorMethodResponse.cannotCalculateChanges, message: message);
}
class NoNetworkError extends RemoteException {
const NoNetworkError() : super(message: RemoteException.noNetworkError);
@override
List<Object?> get props => [message];
}
@@ -1,14 +1,26 @@
import 'package:core/utils/app_logger.dart';
import 'package:dio/dio.dart';
import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.dart';
import 'package:jmap_dart_client/jmap/core/error/method/exception/error_method_response_exception.dart';
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
import 'package:tmail_ui_user/features/network_status_handle/presentation/network_connnection_controller.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
class RemoteExceptionThrower extends ExceptionThrower {
@override
void throwException(dynamic error) {
logError('RemoteExceptionThrower::throwException():error: $error');
final networkConnectionController = getBinding<NetworkConnectionController>();
if (networkConnectionController != null) {
log('RemoteExceptionThrower::throwException(): CONNECTION: ${networkConnectionController.connectivityResult.value}');
if (!networkConnectionController.isNetworkConnectionAvailable()) {
throw const NoNetworkError();
}
}
if (error is DioError) {
switch (error.type) {
case DioErrorType.connectTimeout: