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": {
|
||||
"type": "text",
|
||||
@@ -24,6 +24,12 @@
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"Bad credentials": "Bad credentials",
|
||||
"@Bad credentials": {
|
||||
"type": "text",
|
||||
"placeholders_order": [],
|
||||
"placeholders": {}
|
||||
},
|
||||
"next": "Next",
|
||||
"@next": {
|
||||
"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 {
|
||||
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,
|
||||
|
||||
@@ -36,6 +36,10 @@ class AppLocalizations {
|
||||
String get loginInputCredentialMessage {
|
||||
return Intl.message('Enter your credentials to sign in', name: 'loginInputCredentialMessage');
|
||||
}
|
||||
|
||||
String get badCredentials {
|
||||
return Intl.message('Bad credentials');
|
||||
}
|
||||
|
||||
String get next {
|
||||
return Intl.message('Next', name: 'next');
|
||||
|
||||
Reference in New Issue
Block a user