From 8d76ca26d5057580c281dadbb45e2fc7fcb0e8e3 Mon Sep 17 00:00:00 2001 From: dankl Date: Sun, 13 Oct 2019 18:30:58 +0200 Subject: [PATCH] Handling and logging now also dialog end response; logging web request errors --- .../src/main/kotlin/net/dankito/fints/FinTsClient.kt | 11 +++++++---- .../main/kotlin/net/dankito/fints/model/BankData.kt | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index 0351148f..8c9f4eac 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -61,7 +61,7 @@ open class FinTsClient( val dialogEndRequestBody = messageBuilder.createAnonymousDialogEndMessage(bank, dialogData) - getResponseForMessage(dialogEndRequestBody, bank) + getAndHandleResponseForMessage(dialogEndRequestBody, bank) } @@ -185,14 +185,14 @@ open class FinTsClient( val dialogEndRequestBody = messageBuilder.createDialogEndMessage(bank, customer, dialogData) - getResponseForMessage(dialogEndRequestBody, bank) + getAndHandleResponseForMessage(dialogEndRequestBody, bank) } protected open fun getAndHandleResponseForMessage(requestBody: String, bank: BankData): Response { val webResponse = getResponseForMessage(requestBody, bank) - return handleResponse(webResponse) + return handleResponse(webResponse, bank) } protected open fun getResponseForMessage(requestBody: String, bank: BankData): WebClientResponse { @@ -205,7 +205,7 @@ open class FinTsClient( ) } - protected open fun handleResponse(webResponse: WebClientResponse): Response { + protected open fun handleResponse(webResponse: WebClientResponse, bank: BankData): Response { val responseBody = webResponse.body if (webResponse.isSuccessful && responseBody != null) { @@ -216,6 +216,9 @@ open class FinTsClient( return responseParser.parse(decodedResponse) } + else { + log.error("Request to $bank (${bank.finTs3ServerAddress}) failed", webResponse.error) + } return Response(false, exception = webResponse.error) } diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/BankData.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/BankData.kt index f2304576..ca1f319f 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/BankData.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/BankData.kt @@ -25,7 +25,7 @@ open class BankData( override fun toString(): String { - return bankCode + return "$name ($bankCode)" } } \ No newline at end of file