Rethrows a clearer error message when a test tx in a test ledger does not create a valid tx.

This commit is contained in:
Joel Dudley 2018-01-22 16:08:26 +00:00 committed by GitHub
parent c8e55ae086
commit 443afb3515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -233,7 +233,11 @@ data class TestLedgerDSLInterpreter private constructor(
val transactionInterpreter = interpretTransactionDsl(transactionBuilder, dsl)
if (fillTransaction) fillTransaction(transactionBuilder)
// Create the WireTransaction
val wireTransaction = transactionInterpreter.toWireTransaction()
val wireTransaction = try {
transactionInterpreter.toWireTransaction()
} catch (e: IllegalStateException) {
throw IllegalStateException("A transaction-DSL block that is part of a test ledger must return a valid transaction.", e)
}
// Record the output states
transactionInterpreter.labelToIndexMap.forEach { label, index ->
if (label in labelToOutputStateAndRefs) {