From 1105dfbed0eb5c5e2c02ee2146dacbf187cfc6f3 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 30 Apr 2020 01:49:59 +0200 Subject: [PATCH] Implemented catching exceptions when decoding Base64 or parsing response (e.g. Baader Bank sometimes returns a HTML page instead of a FinTS response) --- .../src/main/kotlin/net/dankito/fints/FinTsClient.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index b4a15564..ef1fe705 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -626,11 +626,17 @@ open class FinTsClient @JvmOverloads constructor( if (webResponse.isSuccessful && responseBody != null) { - val decodedResponse = decodeBase64Response(responseBody) + try { + val decodedResponse = decodeBase64Response(responseBody) - log.debug("Received message:\n${prettyPrintHbciMessage(decodedResponse)}") + log.debug("Received message:\n${prettyPrintHbciMessage(decodedResponse)}") - return responseParser.parse(decodedResponse) + return responseParser.parse(decodedResponse) + } catch (e: Exception) { + log.error("Could not decode responseBody:\r\n'$responseBody'", e) + + return Response(false, exception = e) + } } else { log.error("Request to $bank (${bank.finTs3ServerAddress}) failed", webResponse.error)