Flow Exceptions among multiple parties

479 views Asked by At

When a multi-party flow fails to complete due to various reasons, what are the recommended approaches to throwing exceptions? While throwing a FlowException with a message shared to other parties, I'd prefer to provide data relevant to them and nothing more. Additionally, I'd like to be able to throw a different exception or take some other action (over and above logging an error) at the current party to provide them with information relevant to itself, including data they'd consider private from the network.

I found a few helpful conversations from the discourse forum, and the following documentation from Corda docs. However, looking through some of the flows (TwoPartyTradeFlow, TwoPartyDealFlow, Cash flows) in the corda release-M14 code didn't yield any useful insight to my above question either. Could you please throw some light on this?

https://docs.corda.net/api-flows.html#flowexception
https://discourse.corda.net/t/flow-exception-handling/599/3

1

There are 1 answers

0
Joel On

A FlowException is a standard exception type. So you can wrap an action that might throw a FlowException in a try/catch block, and then rethrow it with only the information you want to provide to the counterparty. Each party can implement a try/catch to rethrow only the information they wish to share.

Alternatively, I believe rethrowing a normal exception, rather than a FlowException, will not send any information to the counterparty other than that the flow terminated unexpectedly.