I am converting the response body from a webclient call to a specific type in case of errors.
if (clientResponse.statusCode().is4xxClientError() ||
clientResponse.statusCode().is5xxServerError()) {
return clientResponse.bodyToMono(ErrorDetails.class)
.map(e -> log.error("Response status: {}, error: {}", clientResponse.statusCode(), e);
In case of a response payload that cannot be deserialized to this type (ErrorDetails.class) because of a different json structure that expected, i am receiving an initialized object of the type specified in the map method. No error signal is generated.
Response status: 404 NOT_FOUND, error: class Error {\n messages: null\n}
Is there a way to change this behavior's and request an error signal in case the response body cannot be set to the type specified?