better error message

This commit is contained in:
Greg DiCristofaro 2023-08-25 07:56:29 -04:00
parent cfb619aaad
commit 227d32d1c0

View File

@ -158,16 +158,23 @@ class CTCloudHttpClient {
// Parse Response
if (classType != null) {
HttpEntity entity = response.getEntity();
String entityStr = EntityUtils.toString(entity);
O respObj = mapper.readValue(entityStr, classType);
return respObj;
} else {
return null;
if (entity != null) {
String entityStr = EntityUtils.toString(entity);
if (StringUtils.isNotBlank(entityStr)) {
O respObj = mapper.readValue(entityStr, classType);
return respObj;
}
}
}
return null;
} else {
LOGGER.log(Level.WARNING, "Response Received. - Status Error {}", response.getStatusLine());
handleNonOKResponse(response, "");
}
// transform all non-CTCloudException's into a CTCloudException
} catch (CTCloudException ex) {
throw ex;
} catch (Exception ex) {
LOGGER.log(Level.WARNING, "Error when parsing response from CyberTriage Cloud", ex);
throw new CTCloudException(CTCloudException.parseUnknownException(ex), ex);