From b086956f95872fe4b73033ab8a44fbd2e20090b0 Mon Sep 17 00:00:00 2001 From: dankl Date: Sun, 13 Oct 2019 17:53:11 +0200 Subject: [PATCH] Renamed error to exception --- .../src/main/kotlin/net/dankito/fints/FinTsClient.kt | 2 +- .../main/kotlin/net/dankito/fints/response/Response.kt | 10 +++++++--- .../net/dankito/fints/response/ResponseParser.kt | 2 +- .../net/dankito/fints/response/ResponseParserTest.kt | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index a2ce0868..54f26f34 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -192,7 +192,7 @@ open class FinTsClient( return responseParser.parse(decodedResponse) } - return Response(false, error = webResponse.error) + return Response(false, exception = webResponse.error) } protected open fun decodeBase64Response(responseBody: String): String { diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt index 5108f43c..7f8d0088 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt @@ -10,11 +10,15 @@ open class Response constructor( val didReceiveResponse: Boolean, val receivedResponse: String? = null, val receivedSegments: List = listOf(), - val error: Exception? = null + + /** + * When a serious error occurred during web request or response parsing. + */ + val exception: Exception? = null ) { open val responseContainsErrors: Boolean - get() = error == null && messageFeedback?.isError == true + get() = exception == null && messageFeedback?.isError == true open val successful: Boolean get() = didReceiveResponse && responseContainsErrors == false @@ -89,7 +93,7 @@ open class Response constructor( return formattedResponse } - return "Error: $error\n$formattedResponse" + return "Error: $exception\n$formattedResponse" } } \ No newline at end of file diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt index 5f0fb4e4..e8c5abfe 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt @@ -48,7 +48,7 @@ open class ResponseParser @JvmOverloads constructor( } catch (e: Exception) { log.error("Could not parse response '$response'", e) - return Response(true, response, error = e) + return Response(true, response, exception = e) } } diff --git a/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt b/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt index 801c0360..866470b3 100644 --- a/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt +++ b/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt @@ -571,7 +571,7 @@ class ResponseParserTest : FinTsTestBase() { assertThat(result.successful).isTrue() assertThat(result.responseContainsErrors).isFalse() - assertThat(result.error).isNull() + assertThat(result.exception).isNull() assertThat(result.errorsToShowToUser).isEmpty() assertThat(result.receivedResponse).isNotNull()