use of com.uber.cadence.RespondActivityTaskFailedRequest in project cadence-client by uber-java.
the class POJOActivityTaskHandler method mapToActivityFailure.
private ActivityTaskHandler.Result mapToActivityFailure(ActivityTask task, Throwable failure) {
if (failure instanceof Error) {
throw (Error) failure;
}
if (failure instanceof ActivityCancelledException) {
throw new CancellationException(failure.getMessage());
}
RespondActivityTaskFailedRequest result = new RespondActivityTaskFailedRequest();
failure = CheckedExceptionWrapper.unwrap((Exception) failure);
result.setReason(failure.getClass().getName());
result.setDetails(dataConverter.toData(failure));
return new ActivityTaskHandler.Result(null, result, null, null);
}
use of com.uber.cadence.RespondActivityTaskFailedRequest in project cadence-client by uber-java.
the class ManualActivityCompletionClientImpl method fail.
@Override
public void fail(Throwable failure) {
if (failure == null) {
throw new IllegalArgumentException("null failure");
}
// When converting failures reason is class name, details are serialized exception.
if (taskToken != null) {
RespondActivityTaskFailedRequest request = new RespondActivityTaskFailedRequest();
request.setReason(failure.getClass().getName());
request.setDetails(dataConverter.toData(failure));
request.setTaskToken(taskToken);
try {
service.RespondActivityTaskFailed(request);
} catch (EntityNotExistsError e) {
throw new ActivityNotExistsException(e);
} catch (TException e) {
throw new ActivityCompletionFailureException(e);
}
} else {
RespondActivityTaskFailedByIDRequest request = new RespondActivityTaskFailedByIDRequest();
request.setReason(failure.getClass().getName());
request.setDetails(dataConverter.toData(failure));
request.setDomain(domain);
request.setWorkflowID(execution.getWorkflowId());
request.setRunID(execution.getRunId());
try {
service.RespondActivityTaskFailedByID(request);
} catch (EntityNotExistsError e) {
throw new ActivityNotExistsException(e);
} catch (TException e) {
throw new ActivityCompletionFailureException(activityId, e);
}
}
}
Aggregations