TF-196 Implement RemoteExceptionThrower when get session
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
abstract class AuthenticationException extends Equatable {
|
||||
import 'package:core/domain/exceptions/remote_exception.dart';
|
||||
|
||||
abstract class AuthenticationException extends RemoteException {
|
||||
static const wrongCredential = 'Credential is wrong';
|
||||
static const badGateway = 'Bad gateway';
|
||||
static const invalidBaseUrl = 'Invalid base URL';
|
||||
|
||||
const AuthenticationException(String message);
|
||||
AuthenticationException(String message) : super(message: message);
|
||||
}
|
||||
|
||||
class BadCredentials extends AuthenticationException {
|
||||
const BadCredentials() : super(AuthenticationException.wrongCredential);
|
||||
BadCredentials() : super(AuthenticationException.wrongCredential);
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
|
||||
class BadGateway extends AuthenticationException {
|
||||
BadGateway() : super(AuthenticationException.badGateway);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
|
||||
class NotFoundAuthenticatedAccountException implements Exception {
|
||||
@@ -23,10 +32,10 @@ class NotFoundStoredTokenException implements Exception {
|
||||
}
|
||||
|
||||
class InvalidBaseUrl extends AuthenticationException {
|
||||
const InvalidBaseUrl() : super(AuthenticationException.invalidBaseUrl);
|
||||
InvalidBaseUrl() : super(AuthenticationException.invalidBaseUrl);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
|
||||
class NotFoundAccessTokenException implements Exception {
|
||||
|
||||
@@ -20,7 +20,7 @@ class GetCredentialInteractor {
|
||||
if (isCredentialValid(baseUrl)) {
|
||||
return Right(GetCredentialViewState(baseUrl, userName, password));
|
||||
} else {
|
||||
return Left(GetCredentialFailure(const BadCredentials()));
|
||||
return Left(GetCredentialFailure(BadCredentials()));
|
||||
}
|
||||
} catch (exception) {
|
||||
return Left(GetCredentialFailure(exception));
|
||||
|
||||
@@ -35,7 +35,7 @@ class GetStoredTokenOidcInteractor {
|
||||
if (_isCredentialValid(baseUrl)) {
|
||||
yield Right(GetStoredTokenOidcSuccess(baseUrl, tokenOidc, oidcConfiguration));
|
||||
} else {
|
||||
yield Left(GetStoredTokenOidcFailure(const InvalidBaseUrl()));
|
||||
yield Left(GetStoredTokenOidcFailure(InvalidBaseUrl()));
|
||||
}
|
||||
} catch (e) {
|
||||
log('GetStoredTokenOidcInteractor::execute(): $e');
|
||||
|
||||
Reference in New Issue
Block a user