Added ErrorCode.NetworkError

This commit is contained in:
dankito 2022-02-26 20:13:49 +01:00
parent 53bfc2d978
commit ef1f987dd1
4 changed files with 7 additions and 2 deletions

View File

@ -5,6 +5,8 @@ enum class ErrorCode {
BankDoesNotSupportFinTs3,
NetworkError,
InternalError,
BankReturnedError,

View File

@ -98,6 +98,7 @@ open class FinTsModelMapper {
open fun mapErrorCode(response: FinTsClientResponse): ErrorCode? {
return when {
response.didReceiveResponse == false -> ErrorCode.NetworkError
response.internalError != null -> ErrorCode.InternalError
response.errorMessagesFromBank.isNotEmpty() -> ErrorCode.BankReturnedError
response.isPinLocked -> ErrorCode.AccountLocked

View File

@ -10,6 +10,8 @@ open class FinTsClientResponse(
open val successful: Boolean,
open val didReceiveResponse: Boolean,
open val noTanMethodSelected: Boolean,
open val isStrongAuthenticationRequired: Boolean,
@ -40,7 +42,7 @@ open class FinTsClientResponse(
) {
constructor(context: JobContext, response: BankResponse) : this(response.successful, response.noTanMethodSelected,
constructor(context: JobContext, response: BankResponse) : this(response.successful, response.didReceiveResponse, response.noTanMethodSelected,
response.isStrongAuthenticationRequired, response.tanResponse, context.messageLogWithoutSensitiveData,
response.internalError, response.errorsToShowToUser, response.isPinLocked, response.wrongCredentialsEntered,
response.tanRequiredButUserDidNotEnterOne, response.tanRequiredButWeWereToldToAbortIfSo,

View File

@ -6,7 +6,7 @@ import net.dankito.banking.fints.model.RetrievedAccountData
open class GetTransactionsResponse(
open val retrievedResponses: List<GetAccountTransactionsResponse>,
errorMessage: String? = null
) : FinTsClientResponse(isSuccessful(retrievedResponses), retrievedResponses.any { it.noTanMethodSelected },
) : FinTsClientResponse(isSuccessful(retrievedResponses), retrievedResponses.all { it.didReceiveResponse }, retrievedResponses.any { it.noTanMethodSelected },
retrievedResponses.any { it.isStrongAuthenticationRequired }, retrievedResponses.map { it.tanRequired }.firstOrNull(),
retrievedResponses.flatMap { it.messageLogWithoutSensitiveData },
errorMessage ?: retrievedResponses.mapNotNull { it.internalError }.joinToString("\r\n"),