Skip to content
Ameen Abozaid
Planned lessonMID-006-L03

Errors in async code

  • Lesson 3 of 6
  • Mid-level
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

propagate and handle failures.

Planned topics

  • An exception completes the stage exceptionally; dependent stages are skipped and carry it forward.
  • exceptionally(fn): recover with a fallback value.
  • handle((v, ex) -> ...): see both result and error; whenComplete observes without changing.
  • join() throws CompletionException; get() throws ExecutionException; the cause is wrapped.
  • An unobserved failed future loses the error silently; always attach handling or read it.
Draft outline details

Demonstration

java
CompletableFuture<List<Review>> r = reviewsF.exceptionally(ex -> List.of()); // degrade gracefully

Check your understanding

What does a downstream thenApply do when its source failed?

Show answer

It is skipped and the failure propagates.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.