Trying to get inner exception for errorToShowToUser

This commit is contained in:
dankl 2020-01-08 22:59:33 +01:00 committed by dankito
parent 7fbd6159ac
commit ce58ef60ca
1 changed files with 7 additions and 1 deletions

View File

@ -11,12 +11,16 @@ import net.dankito.fints.model.BankData
import net.dankito.fints.model.CustomerData
import net.dankito.fints.response.client.FinTsClientResponse
import net.dankito.fints.response.segments.AccountType
import net.dankito.utils.exception.ExceptionHelper
import java.math.BigDecimal
open class fints4javaModelMapper {
private val exceptionHelper = ExceptionHelper()
open fun mapResponse(response: FinTsClientResponse): BankingClientResponse {
return BankingClientResponse(response.isSuccessful, mapErrorToShowToUser(response), response.exception)
}
@ -48,7 +52,9 @@ open class fints4javaModelMapper {
}
open fun mapErrorToShowToUser(response: FinTsClientResponse): String? {
return response.exception?.localizedMessage ?: response.errorsToShowToUser.joinToString("\n")
val innerException = response.exception?.let { exception -> exceptionHelper.getInnerException(exception) }
return innerException?.localizedMessage ?: response.errorsToShowToUser.joinToString("\n")
}