class CamundaClient {

    protected BPMNFailureException createBPMNFailureException(HttpStatusCodeException e) {
        ObjectMapper mapper = new ObjectMapper();
        String responseText = null;
        String message = null;
        try {
            CamundaResponse response = mapper.readValue(e.getResponseBodyAsString(), CamundaResponse.class);
            responseText = response.getResponse();
        } catch (IOException ex) {
            responseText = e.getResponseBodyAsString();
        }
        message = String.valueOf(e.getStatusCode());
        if (responseText != null && !responseText.isEmpty()) {
            message = message + " " + responseText;
        }
        BPMNFailureException bpmnException =
                new BPMNFailureException.Builder(message, responseHandler.setStatus(e.getStatusCode().value()),
                        ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, e.getStatusCode()).build();
        return bpmnException;
    }

}