Renamed error to exception
This commit is contained in:
parent
8d4d279e66
commit
b086956f95
|
@ -192,7 +192,7 @@ open class FinTsClient(
|
||||||
return responseParser.parse(decodedResponse)
|
return responseParser.parse(decodedResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response(false, error = webResponse.error)
|
return Response(false, exception = webResponse.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun decodeBase64Response(responseBody: String): String {
|
protected open fun decodeBase64Response(responseBody: String): String {
|
||||||
|
|
|
@ -10,11 +10,15 @@ open class Response constructor(
|
||||||
val didReceiveResponse: Boolean,
|
val didReceiveResponse: Boolean,
|
||||||
val receivedResponse: String? = null,
|
val receivedResponse: String? = null,
|
||||||
val receivedSegments: List<ReceivedSegment> = listOf(),
|
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
|
open val responseContainsErrors: Boolean
|
||||||
get() = error == null && messageFeedback?.isError == true
|
get() = exception == null && messageFeedback?.isError == true
|
||||||
|
|
||||||
open val successful: Boolean
|
open val successful: Boolean
|
||||||
get() = didReceiveResponse && responseContainsErrors == false
|
get() = didReceiveResponse && responseContainsErrors == false
|
||||||
|
@ -89,7 +93,7 @@ open class Response constructor(
|
||||||
return formattedResponse
|
return formattedResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Error: $error\n$formattedResponse"
|
return "Error: $exception\n$formattedResponse"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -48,7 +48,7 @@ open class ResponseParser @JvmOverloads constructor(
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
log.error("Could not parse response '$response'", e)
|
log.error("Could not parse response '$response'", e)
|
||||||
|
|
||||||
return Response(true, response, error = e)
|
return Response(true, response, exception = e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -571,7 +571,7 @@ class ResponseParserTest : FinTsTestBase() {
|
||||||
|
|
||||||
assertThat(result.successful).isTrue()
|
assertThat(result.successful).isTrue()
|
||||||
assertThat(result.responseContainsErrors).isFalse()
|
assertThat(result.responseContainsErrors).isFalse()
|
||||||
assertThat(result.error).isNull()
|
assertThat(result.exception).isNull()
|
||||||
assertThat(result.errorsToShowToUser).isEmpty()
|
assertThat(result.errorsToShowToUser).isEmpty()
|
||||||
assertThat(result.receivedResponse).isNotNull()
|
assertThat(result.receivedResponse).isNotNull()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue