Add BadCredentialsException
This commit is contained in:
@@ -6,6 +6,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';
|
||||
static const badCredentials = 'Bad credentials';
|
||||
|
||||
final String? message;
|
||||
final int? code;
|
||||
@@ -13,6 +14,13 @@ abstract class RemoteException with EquatableMixin implements Exception {
|
||||
const RemoteException({this.code, this.message});
|
||||
}
|
||||
|
||||
class BadCredentialsException extends RemoteException {
|
||||
const BadCredentialsException() : super(message: RemoteException.badCredentials);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class UnknownError extends RemoteException {
|
||||
const UnknownError({int? code, String? message}) : super(code: code, message: message);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:get/get_connect/http/src/status/http_status.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';
|
||||
@@ -15,7 +16,6 @@ class RemoteExceptionThrower extends ExceptionThrower {
|
||||
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();
|
||||
}
|
||||
@@ -28,6 +28,8 @@ class RemoteExceptionThrower extends ExceptionThrower {
|
||||
default:
|
||||
if (error.response?.statusCode == 502) {
|
||||
throw BadGateway();
|
||||
} else if (error.response?.statusCode == HttpStatus.unauthorized) {
|
||||
throw const BadCredentialsException();
|
||||
} else {
|
||||
throw UnknownError(
|
||||
code: error.response?.statusCode,
|
||||
|
||||
Reference in New Issue
Block a user