if (tryAndIdentifyError && response!=null && baos!=null && requestErrorSetter!=null) {
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectMapper errorMapper=new ObjectMapper();
try {
RequestErrorWrapper errorResponse=errorMapper.readValue(bais, RequestErrorWrapper.class);
if (errorResponse!=null && errorResponse.getRequestError()!=null) {
requestErrorSetter.invoke(response, errorResponse.getRequestError());
}
} catch (Exception e) {
logger.warn("Exception "+e.getMessage()+" trying to identify error response");
}