INNER CODE UNIT · Java
readEntity
Erudika/para · para-client/src/main/java/com/erudika/para/client/ParaClient.java:448
private <T> T readEntity(HttpEntity respEntity, Class<?> returnType, int statusCode, String reason) throws IOException {
if (respEntity != null) {
if (statusCode == HttpStatus.SC_OK
|| statusCode == HttpStatus.SC_CREATED
|| statusCode == HttpStatus.SC_NOT_MODIFIED) {
return readEntity(respEntity, returnType);
} else if (statusCode != HttpStatus.SC_NOT_FOUND
&& statusCode != HttpStatus.SC_NOT_MODIFIED
&& statusCode != HttpStatus.SC_NO_CONTENT) {
Map<String, Object> error = readEntity(respEntity, Map.class);
if (error != null && error.containsKey("code")) {
String msg = error.containsKey("message") ? (String) error.get("message") : "error";
RuntimeException e = new RuntimeException((Integer) error.get("code") + " - " + msg);
logger.error("{} - {}", error.get("code"), e.getMessage());
if (throwExceptionOnHTTPError) {
throw e;
} else if (returnType == null) {
return (T) error;