From 1626969632f5ee689e54193bb2a6b45deda65c5f Mon Sep 17 00:00:00 2001 From: Konstantin Munichev <konstantin.munichev@neclab.eu> Date: Wed, 20 Jul 2022 16:44:15 +0200 Subject: [PATCH] Return empty DltRecord when no data was recorded in blockchain --- .../gateway/src/main/kotlin/fabric/FabricConnector.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dlt/gateway/src/main/kotlin/fabric/FabricConnector.kt b/src/dlt/gateway/src/main/kotlin/fabric/FabricConnector.kt index 53e88a56f..d6feaa0ab 100644 --- a/src/dlt/gateway/src/main/kotlin/fabric/FabricConnector.kt +++ b/src/dlt/gateway/src/main/kotlin/fabric/FabricConnector.kt @@ -134,9 +134,14 @@ class FabricConnector(val config: Config.DltConfig) { } fun getData(uuid: String): DltRecord { - val result = contract.evaluateTransaction("GetRecord", uuid) - println("Get: ${result.size}") - return DltRecord.parseFrom(result) + try { + val result = contract.evaluateTransaction("GetRecord", uuid) + println("Get: ${result.size}") + return DltRecord.parseFrom(result) + } catch (e: Exception) { + println(e.toString()) + return DltRecord.getDefaultInstance() + } } fun updateData(record: DltRecord): String { -- GitLab