Search in sources :

Example 1 with Builder

use of org.kie.internal.runtime.error.ExecutionError.Builder in project jbpm by kiegroup.

the class TaskExecutionErrorFilter method filter.

@Override
public ExecutionError filter(ExecutionErrorContext errorContext) {
    if (isCausedBy(errorContext.getCause(), PermissionDeniedException.class)) {
        return null;
    }
    Builder taskErrorBuilder = ExecutionError.builder().type(TYPE).initActivityId(getInitActivityId(errorContext));
    TaskException exception = extract(errorContext.getCause(), TaskException.class);
    String stacktrace = getStackTrace(exception);
    Task task = errorContext.getLastExecutedTask();
    if (task != null) {
        taskErrorBuilder.deploymentId(task.getTaskData().getDeploymentId()).processInstanceId(task.getTaskData().getProcessInstanceId()).processId(task.getTaskData().getProcessId()).activityId(task.getId()).activityName(task.getName());
    }
    return taskErrorBuilder.message(exception.getMessage()).error(stacktrace).errorDate(new Date()).build();
}
Also used : Task(org.kie.api.task.model.Task) TaskException(org.kie.internal.task.exception.TaskException) Builder(org.kie.internal.runtime.error.ExecutionError.Builder) Date(java.util.Date)

Example 2 with Builder

use of org.kie.internal.runtime.error.ExecutionError.Builder in project jbpm by kiegroup.

the class DBExecutionErrorFilter method filter.

@Override
public ExecutionError filter(ExecutionErrorContext errorContext) {
    Builder errorBuilder = ExecutionError.builder().type(TYPE).initActivityId(getInitActivityId(errorContext));
    String stacktrace = getStackTrace(errorContext.getCause());
    Task task = errorContext.getLastExecutedTask();
    NodeInstance nodeInstance = errorContext.getLastExecutedNode();
    logger.debug("Last executed node instance {}, last executed task {}", nodeInstance, task);
    if (nodeInstance != null) {
        logger.debug("Last executed node instance {} will be used to populate error details", nodeInstance);
        errorBuilder.deploymentId(((ProcessInstanceImpl) nodeInstance.getProcessInstance()).getDeploymentId()).processInstanceId(nodeInstance.getProcessInstance().getId()).processId(nodeInstance.getProcessInstance().getProcessId()).activityId(nodeInstance.getId()).activityName(nodeName(nodeInstance));
    } else if (task != null) {
        logger.debug("Last executed task {} will be used to populate error details", task);
        errorBuilder.deploymentId(task.getTaskData().getDeploymentId()).processInstanceId(task.getTaskData().getProcessInstanceId()).processId(task.getTaskData().getProcessId()).activityId(task.getId()).activityName(task.getName());
    }
    return errorBuilder.message(errorContext.getCause().getMessage()).error(stacktrace).errorDate(new Date()).build();
}
Also used : Task(org.kie.api.task.model.Task) Builder(org.kie.internal.runtime.error.ExecutionError.Builder) NodeInstance(org.kie.api.runtime.process.NodeInstance) Date(java.util.Date)

Aggregations

Date (java.util.Date)2 Task (org.kie.api.task.model.Task)2 Builder (org.kie.internal.runtime.error.ExecutionError.Builder)2 NodeInstance (org.kie.api.runtime.process.NodeInstance)1 TaskException (org.kie.internal.task.exception.TaskException)1