Add BadCredentialsException
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2023-03-02T21:08:14.879842",
|
"@@last_modified": "2023-03-03T11:59:08.917209",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -24,6 +24,12 @@
|
|||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
|
"Bad credentials": "Bad credentials",
|
||||||
|
"@Bad credentials": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
"next": "Next",
|
"next": "Next",
|
||||||
"@next": {
|
"@next": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.da
|
|||||||
abstract class RemoteException with EquatableMixin implements Exception {
|
abstract class RemoteException with EquatableMixin implements Exception {
|
||||||
static const connectError = 'Connect error';
|
static const connectError = 'Connect error';
|
||||||
static const noNetworkError = 'No network error';
|
static const noNetworkError = 'No network error';
|
||||||
|
static const badCredentials = 'Bad credentials';
|
||||||
|
|
||||||
final String? message;
|
final String? message;
|
||||||
final int? code;
|
final int? code;
|
||||||
@@ -13,6 +14,13 @@ abstract class RemoteException with EquatableMixin implements Exception {
|
|||||||
const RemoteException({this.code, this.message});
|
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 {
|
class UnknownError extends RemoteException {
|
||||||
const UnknownError({int? code, String? message}) : super(code: code, message: message);
|
const UnknownError({int? code, String? message}) : super(code: code, message: message);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dio/dio.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/error_method_response.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/error/method/exception/error_method_response_exception.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/login/domain/exceptions/authentication_exception.dart';
|
||||||
@@ -15,7 +16,6 @@ class RemoteExceptionThrower extends ExceptionThrower {
|
|||||||
logError('RemoteExceptionThrower::throwException():error: $error');
|
logError('RemoteExceptionThrower::throwException():error: $error');
|
||||||
final networkConnectionController = getBinding<NetworkConnectionController>();
|
final networkConnectionController = getBinding<NetworkConnectionController>();
|
||||||
if (networkConnectionController != null) {
|
if (networkConnectionController != null) {
|
||||||
log('RemoteExceptionThrower::throwException(): CONNECTION: ${networkConnectionController.connectivityResult.value}');
|
|
||||||
if (!networkConnectionController.isNetworkConnectionAvailable()) {
|
if (!networkConnectionController.isNetworkConnectionAvailable()) {
|
||||||
throw const NoNetworkError();
|
throw const NoNetworkError();
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,8 @@ class RemoteExceptionThrower extends ExceptionThrower {
|
|||||||
default:
|
default:
|
||||||
if (error.response?.statusCode == 502) {
|
if (error.response?.statusCode == 502) {
|
||||||
throw BadGateway();
|
throw BadGateway();
|
||||||
|
} else if (error.response?.statusCode == HttpStatus.unauthorized) {
|
||||||
|
throw const BadCredentialsException();
|
||||||
} else {
|
} else {
|
||||||
throw UnknownError(
|
throw UnknownError(
|
||||||
code: error.response?.statusCode,
|
code: error.response?.statusCode,
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ class AppLocalizations {
|
|||||||
return Intl.message('Enter your credentials to sign in', name: 'loginInputCredentialMessage');
|
return Intl.message('Enter your credentials to sign in', name: 'loginInputCredentialMessage');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get badCredentials {
|
||||||
|
return Intl.message('Bad credentials');
|
||||||
|
}
|
||||||
|
|
||||||
String get next {
|
String get next {
|
||||||
return Intl.message('Next', name: 'next');
|
return Intl.message('Next', name: 'next');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user