Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. CompletableFuture<String> future = new CompletableFuture<>();
  2.  
  3. future.completeExceptionally(new RuntimeException());
  4.  
  5. future.exceptionally(e -> {
  6. System.out.println(e.getClass());
  7. return null;
  8. });
  9.  
  10. CompletableFuture<String> future = new CompletableFuture<>();
  11.  
  12. future.completeExceptionally(new RuntimeException());
  13.  
  14. future.thenApply(v-> v).exceptionally(e -> {
  15. System.out.println(e);
  16. return null;
  17. });
  18.  
  19. CompletableFuture<String> future = new CompletableFuture<>();
  20.  
  21. future.completeExceptionally(new RuntimeException());
  22.  
  23. future.thenApply(v-> v).exceptionally(e -> {
  24. System.out.println(e.getCause()); // returns a throwable back
  25. return null;
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement