Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Handling Tools for MultiException #350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wiilei
Copy link

@wiilei wiilei commented Jun 10, 2024

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