private void failTask(Task task, String errorMsg) {
        try {
            TaskResult taskResult = new TaskResult();
            taskResult.setStatus(TaskResult.Status.FAILED);
            taskResult.setTaskId(task.getTaskId());
            taskResult.setWorkflowInstanceId(task.getWorkflowInstanceId());
            taskResult.setReasonForIncompletion(errorMsg);
            executionService.updateTask(taskResult);
        } catch (Exception e) {
            LOGGER.error(
                    "Unable to fail task: {} in workflow: {}",
                    task.getTaskId(),
                    task.getWorkflowInstanceId(),
                    e);
            executionService.terminateWorkflow(
                    task.getWorkflowInstanceId(), "Failed to ack task: " + task.getTaskId());
        }
    }
Updates the task with FAILED status; On exception, fails the workflow.
core/src/main/java/com/netflix/conductor/service/TaskServiceImpl.java