Fix exchangeToMono sample in reference

Closes gh-26189
This commit is contained in:
Rossen Stoyanchev 2020-12-01 16:44:20 +00:00
parent 69aed83504
commit 1e19e51c9c
1 changed files with 29 additions and 27 deletions

View File

@ -554,10 +554,12 @@ depending on the response status:
return response.bodyToMono(Person.class);
}
else if (response.statusCode().is4xxClientError()) {
// Suppress error status code
return response.bodyToMono(ErrorContainer.class);
}
else {
return Mono.error(response.createException());
// Turn to error
return response.createException().flatMap(Mono::error);
}
});
----
@ -569,13 +571,13 @@ depending on the response status:
.accept(MediaType.APPLICATION_JSON)
.awaitExchange {
if (response.statusCode() == HttpStatus.OK) {
return response.awaitBody<Person>();
return response.awaitBody<Person>()
}
else if (response.statusCode().is4xxClientError) {
return response.awaitBody<ErrorContainer>();
return response.awaitBody<ErrorContainer>()
}
else {
return response.createExceptionAndAwait();
throw response.createExceptionAndAwait()
}
}
----