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);
}
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);
}
}
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);
}
Aggregations