Renamed error to exception

This commit is contained in:
dankl 2019-10-13 17:53:11 +02:00 committed by dankito
parent 8d4d279e66
commit b086956f95
4 changed files with 10 additions and 6 deletions

View File

@ -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 {

View File

@ -10,11 +10,15 @@ open class Response constructor(
val didReceiveResponse: Boolean,
val receivedResponse: String? = null,
val receivedSegments: List<ReceivedSegment> = 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"
}
}

View File

@ -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)
}
}

View File

@ -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()