Marcus Cvjeticanin
04/18/2023, 8:15 PMsuspend fun getBlockDetailsByHeight(blockDetailsByHeightRequest: BlockDetailsByHeightRequest): BlockDetail? {
val jsonBody = Json.encodeToString(blockDetailsByHeightRequest)
val builder = HttpRequestBuilder().apply {
method = <http://HttpMethod.Post|HttpMethod.Post>
node.ssl.let {
if (it) {
url.takeFrom("https://${node.hostName}:${node.port}/get_block_details_by_height")
} else {
url.takeFrom("http://${node.hostName}:${node.port}/get_block_details_by_height")
}
}
contentType(ContentType.Application.Json)
headers {
append("Content-Length", jsonBody.length.toString())
}
setBody(jsonBody)
}
try {
return <http://client.post|client.post>(builder).body<BlockDetail>()
} catch (e: Exception) {
logger.error("Error getting block details by height", e)
}
return null
}
It complains about exception being to generic. Which is true. But what kind of exception(s) should I try to catch here? I'm trying to figure out by checking the client.post or client.get functions, but I can't seem to find what will be throwned. Any idea?Chris Overcash
04/18/2023, 8:46 PMJsonConvertException
, UnresolvedAddressException
, and ClientRequestException
simon.vergauwen
04/19/2023, 5:03 AMException
also captures CancellationException
which can be problematic for structured concurrency