FlowException
Keywords: net.corda.core.flows.FlowException class
Date: 2023-09-18

net.corda.core.flows

## Class FlowException

-     public class FlowException

  Exception which can be thrown by a `class FlowLogic` at any point in its logic to unexpectedly bring it to a permanent end. The exception will propagate to all counterparty flows and will be thrown on their end the next time they wait on a FlowSession.receive or FlowSession.sendAndReceive. Any flow which no longer needs to do a receive, or has already ended, will not receive the exception (if this is required then have them wait for a confirmation message).

  If the rethrown `exception FlowException` is uncaught in counterparty flows and propagation triggers then the exception is downgraded to an `exception UnexpectedFlowEndException`. This means only immediate counterparty flows will receive information about what the exception was.

  `exception FlowException` (or a subclass) can be a valid expected response from a flow, particularly ones which act as a service. It is recommended a `class FlowLogic` document the `exception FlowException` types it can throw.

  See Also:
    `class FlowLogic`, `exception FlowException`, `exception UnexpectedFlowEndException`, `exception FlowException`, `class FlowLogic`, `exception FlowException`

- - ### Constructor Detail

    - #### FlowException

          public FlowException(@Nullable
                               java.lang.String message,
                               @Nullable
                               java.lang.Throwable cause,
                               @Nullable
                               java.lang.Long originalErrorId)

      Exception which can be thrown by a `class FlowLogic` at any point in its logic to unexpectedly bring it to a permanent end. The exception will propagate to all counterparty flows and will be thrown on their end the next time they wait on a FlowSession.receive or FlowSession.sendAndReceive. Any flow which no longer needs to do a receive, or has already ended, will not receive the exception (if this is required then have them wait for a confirmation message).

      If the rethrown `exception FlowException` is uncaught in counterparty flows and propagation triggers then the exception is downgraded to an `exception UnexpectedFlowEndException`. This means only immediate counterparty flows will receive information about what the exception was.

      `exception FlowException` (or a subclass) can be a valid expected response from a flow, particularly ones which act as a service. It is recommended a `class FlowLogic` document the `exception FlowException` types it can throw.

      Parameters:
        `originalErrorId` - the ID backing `getErrorId`. If null it will be set dynamically by the flow framework when the exception is handled. This ID is propagated to counterparty flows, even when the `exception FlowException` is downgraded to an `exception UnexpectedFlowEndException`. This is so the error conditions may be correlated later on.
      See Also:
        `class FlowLogic`, `exception FlowException`, `exception UnexpectedFlowEndException`, `exception FlowException`, `class FlowLogic`, `exception FlowException`

    - #### FlowException

          public FlowException(@Nullable
                               java.lang.String message,
                               @Nullable
                               java.lang.Throwable cause)

    - #### FlowException

          public FlowException(@Nullable
                               java.lang.String message)

    - #### FlowException

          public FlowException(@Nullable
                               java.lang.Throwable cause)

    - #### FlowException

          public FlowException()

  - ### Method Detail

    - #### getErrorId

          @Nullable
          public java.lang.Long getErrorId()

    - #### getOriginalErrorId

          @Nullable
          public java.lang.Long getOriginalErrorId()

      the ID backing

      `getErrorId`. If null it will be set dynamically by the flow framework when the exception is handled. This ID is propagated to counterparty flows, even when the `exception FlowException` is downgraded to an `exception UnexpectedFlowEndException`. This is so the error conditions may be correlated later on.

      See Also:
        `getErrorId`, `exception FlowException`, `exception UnexpectedFlowEndException`

    - #### setOriginalErrorId

          public void setOriginalErrorId(@Nullable
                                         java.lang.Long p)

      the ID backing

      `getErrorId`. If null it will be set dynamically by the flow framework when the exception is handled. This ID is propagated to counterparty flows, even when the `exception FlowException` is downgraded to an `exception UnexpectedFlowEndException`. This is so the error conditions may be correlated later on.

      Parameters:
        `p` - the ID backing `getErrorId`. If null it will be set dynamically by the flow framework when the exception is handled. This ID is propagated to counterparty flows, even when the `exception FlowException` is downgraded to an `exception UnexpectedFlowEndException`. This is so the error conditions may be correlated later on.
      See Also:
        `getErrorId`, `exception FlowException`, `exception UnexpectedFlowEndException`