Search in sources :

Example 1 with ProcessInstanceExecutionException

use of io.automatiko.engine.api.workflow.ProcessInstanceExecutionException in project automatiko-engine by automatiko-io.

the class ProcessInstanceExecutionExceptionMapper method toResponse.

@Override
public Response toResponse(ProcessInstanceExecutionException ex) {
    ProcessInstanceExecutionException exception = (ProcessInstanceExecutionException) ex;
    Map<String, String> response = new HashMap<>();
    response.put(ID, exception.getProcessInstanceId());
    response.put(FAILED_NODE_ID, exception.getFailedNodeId());
    response.put(MESSAGE, exception.getErrorMessage());
    return internalError(response);
}
Also used : ProcessInstanceExecutionException(io.automatiko.engine.api.workflow.ProcessInstanceExecutionException) HashMap(java.util.HashMap)

Example 2 with ProcessInstanceExecutionException

use of io.automatiko.engine.api.workflow.ProcessInstanceExecutionException in project automatiko-engine by automatiko-io.

the class UnitOfWorkExecutor method executeInUnitOfWork.

public static <T> T executeInUnitOfWork(UnitOfWorkManager uowManager, Supplier<T> supplier) {
    T result = null;
    UnitOfWork uow = uowManager.newUnitOfWork();
    try {
        uow.start();
        result = supplier.get();
        uow.end();
        return result;
    } catch (ProcessInstanceExecutionException e) {
        uow.end();
        throw e;
    } catch (ConflictingVersionException e) {
        LOGGER.warn("A conflict was identified for current unit of work with message '{}', aborting current unit of work and retrying", e.getMessage());
        uow.abort();
        return executeInUnitOfWork(uowManager, supplier);
    } catch (Exception e) {
        e.printStackTrace();
        uow.abort();
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        } else {
            throw new RuntimeException(e);
        }
    } finally {
        // reset identity provider upon completion of the unit of work
        IdentityProvider.set(null);
    }
}
Also used : UnitOfWork(io.automatiko.engine.api.uow.UnitOfWork) ConflictingVersionException(io.automatiko.engine.api.workflow.ConflictingVersionException) ProcessInstanceExecutionException(io.automatiko.engine.api.workflow.ProcessInstanceExecutionException) ProcessInstanceExecutionException(io.automatiko.engine.api.workflow.ProcessInstanceExecutionException) ConflictingVersionException(io.automatiko.engine.api.workflow.ConflictingVersionException)

Example 3 with ProcessInstanceExecutionException

use of io.automatiko.engine.api.workflow.ProcessInstanceExecutionException in project automatiko-engine by automatiko-io.

the class BaseExceptionHandlerTest method testMapProcessInstanceExecutionException.

@Test
void testMapProcessInstanceExecutionException() {
    Object response = tested.mapException(new ProcessInstanceExecutionException("processInstanceId", "nodeId", "message"));
    assertThat(response).isEqualTo(internalErrorResponse);
}
Also used : ProcessInstanceExecutionException(io.automatiko.engine.api.workflow.ProcessInstanceExecutionException) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessInstanceExecutionException (io.automatiko.engine.api.workflow.ProcessInstanceExecutionException)3 UnitOfWork (io.automatiko.engine.api.uow.UnitOfWork)1 ConflictingVersionException (io.automatiko.engine.api.workflow.ConflictingVersionException)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1