Let's say I have incident (org.camunda.bpm.engine.runtime.Incident
) found using RuntimeService.createIncidentQuery()...
.
Is there a way to read actual incident stack trace using Java API? Same stack trace accessible in Cockpit.
If it is failed job then the configuration / payload of the incident will be the job id. If the incident is caused by a failed external task then it will be the external task id.
Hence:
Incident incident = runtimeService.createIncidentQuery().singleResult();
String configuration = incident.getConfiguration();
log.info("Incident type: {}", incident.getIncidentType());
if (incident.getIncidentType().equals(Incident.FAILED_JOB_HANDLER_TYPE)) {
log.info("Here comes the stacktrace: {}", managementService.getJobExceptionStacktrace(configuration));
} else {
log.info("Here come the error details: {}", externalTaskService.getExternalTaskErrorDetails(configuration));
}