} catch (CannotConnectException e) {
LOG.error("Error while sending create resource request to agent service", e);
// Submit the error as a failure response
String errorMessage = ThrowableUtil.getAllMessages(e);
CreateResourceResponse response = new CreateResourceResponse(persistedHistory.getId(), null, null,
CreateResourceStatus.FAILURE, errorMessage, null);
resourceFactoryManager.completeCreateResource(response);
throw new CannotConnectToAgentException("Error while sending create resource request to agent service", e);
} catch (Exception e) {
LOG.error("Error while sending create resource request to agent service", e);
// Submit the error as a failure response
String errorMessage = ThrowableUtil.getAllMessages(e);
CreateResourceResponse response = new CreateResourceResponse(persistedHistory.getId(), null, null,
CreateResourceStatus.FAILURE, errorMessage, null);
resourceFactoryManager.completeCreateResource(response);
throw new RuntimeException("Error while sending create resource request to agent service", e);
}