Skip to content

Instantly share code, notes, and snippets.

@ayushi24041992
Created December 24, 2019 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayushi24041992/18a5fab8b56e4032913128c27f207638 to your computer and use it in GitHub Desktop.
Save ayushi24041992/18a5fab8b56e4032913128c27f207638 to your computer and use it in GitHub Desktop.
@Test
public void fluxErrorHandling(){
Flux<String> stringFlux = Flux.just("a","b","c")
.concatWith(Flux.error(new RuntimeException("Exception Occurred")))
.concatWith(Flux.just("D"))
.onErrorResume((e) -> { // on error this block gets executed - we are returning a flux on error value
System.out.println(e);
return Flux.just("default");
});
StepVerifier.create(stringFlux.log())
.expectSubscription()
.expectNext("a","b","c")
.expectNext("default")
.verifyComplete();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment