Created
December 24, 2019 11:40
-
-
Save ayushi24041992/bd9955509a4bae29d1f72fa99154c58a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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") | |
.expectError(RuntimeException.class) | |
.verify(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment