ENT-4090: move startFlow into try block so exception is caught and managed (#5519)

This commit is contained in:
Ryan Fowler 2019-09-26 17:37:36 +01:00 committed by Shams Asari
parent 9c8048008f
commit be6824dac4

View File

@ -20,7 +20,6 @@ import net.corda.core.contracts.withoutIssuer
import net.corda.core.flows.FlowException import net.corda.core.flows.FlowException
import net.corda.core.identity.Party import net.corda.core.identity.Party
import net.corda.core.identity.PartyAndCertificate import net.corda.core.identity.PartyAndCertificate
import net.corda.core.messaging.FlowHandle
import net.corda.core.messaging.startFlow import net.corda.core.messaging.startFlow
import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.OpaqueBytes
@ -94,15 +93,14 @@ class NewTransaction : Fragment() {
initOwner(window) initOwner(window)
show() show()
} }
val handle: FlowHandle<AbstractCashFlow.Result> = when (request) {
is IssueAndPaymentRequest -> rpcProxy.value!!.startFlow(::CashIssueAndPaymentFlow, request)
is PaymentRequest -> rpcProxy.value!!.startFlow(::CashPaymentFlow, request)
is ExitRequest -> rpcProxy.value!!.startFlow(::CashExitFlow, request)
else -> throw IllegalArgumentException("Unexpected request type: $request")
}
runAsync { runAsync {
try { try {
handle.returnValue.getOrThrow() when (request) {
is IssueAndPaymentRequest -> rpcProxy.value!!.startFlow(::CashIssueAndPaymentFlow, request)
is PaymentRequest -> rpcProxy.value!!.startFlow(::CashPaymentFlow, request)
is ExitRequest -> rpcProxy.value!!.startFlow(::CashExitFlow, request)
else -> throw IllegalArgumentException("Unexpected request type: $request")
}.returnValue.getOrThrow()
} finally { } finally {
dialog.dialogPane.isDisable = false dialog.dialogPane.isDisable = false
} }