parent
69aed83504
commit
1e19e51c9c
|
|
@ -554,28 +554,30 @@ 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);
|
||||
}
|
||||
});
|
||||
----
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
val entity = client.get()
|
||||
val entity = client.get()
|
||||
.uri("/persons/1")
|
||||
.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()
|
||||
}
|
||||
}
|
||||
----
|
||||
|
|
|
|||
Loading…
Reference in New Issue