From df810d10af8e0b44fcb39887e826dacd35f7ef70 Mon Sep 17 00:00:00 2001 From: Andrew Westberg Date: Thu, 5 Sep 2024 19:00:02 +0000 Subject: [PATCH] Improve error message for missing utxo in newm-chain --- .../main/kotlin/io/newm/chain/grpc/NewmChainService.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/newm-chain/src/main/kotlin/io/newm/chain/grpc/NewmChainService.kt b/newm-chain/src/main/kotlin/io/newm/chain/grpc/NewmChainService.kt index 86c86103..d76d3839 100644 --- a/newm-chain/src/main/kotlin/io/newm/chain/grpc/NewmChainService.kt +++ b/newm-chain/src/main/kotlin/io/newm/chain/grpc/NewmChainService.kt @@ -398,9 +398,11 @@ class NewmChainService : NewmChainGrpcKt.NewmChainCoroutineImplBase() { } else { utxos.sumOf { utxo -> val scriptRefHexLength = - ledgerRepository - .queryUtxosByOutputRef(utxo.hash, utxo.ix.toInt()) - .first() + requireNotNull( + ledgerRepository + .queryUtxosByOutputRef(utxo.hash, utxo.ix.toInt()) + .firstOrNull() + ) { "Utxo not found in ledger: ${utxo.hash}#${utxo.ix}" } .scriptRef ?.length ?.toLong()