TF-1361 Fix open notification while no network connection
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user