Skip to content

Conversation

@LeonCode2025
Copy link

Two handling tools for MultiException have been added to reduce the complexity of dealing with nested exceptions when constructing complex ParSeq flows.

  • allMultiCauses: Used to extract custom exceptions wrapped by MultiException, for example:
// Assuming both RPC and HTTP calls failed
Task<?> rpcRespTask = Task.par<RpcA, RpcB>.map(...);
Task<?> httpRespTask = Task.par<HttpA, HttpB>.map(...);
Task<?> task = Task.par(rpcRespTask, httpRespTask)
        .onFailure(e ->  // e: MultiException[MultiException[RpcAE, RpcBE], MultiException[HttpAE, HttpBE]]
                 Collection<Throwable> es = Exceptions.allMultiCauses(e);  // es: [RpcAE, RpcBE, HttpAE, HttpBE]
  • anyMultiCause: Used to retrieve any single actual exception from MultiException, for example:
xxx.onFailure(e ->  // e: MultiException[MultiException[RpcAE, RpcBE], MultiException[HttpAE, HttpBE]]
                           // print: 'com.linkedin.parseq.MultiException (multiple causes follow; only first is shown in stack trace): ...'
                           Logger.error("has remote method error", e);

                           // print: 'com.xxx.RpcException: Rpc A Error ...'
                           Logger.error("has remote method error", Exceptions.anyMultiCause(e));

…l causes and the first non-MultiException cause, respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant