How can i get Service Task's Bpmn Error Activity in Java Delegate

**

just need get bpmn activity on currently service task in java delegate class

**

I’m trying to set up a general error structure. all service tasks run a java class so I need to know if the service task has a bpmn error bound event? otherwise I didn’t send any other custom error code “GlobalError” in bpmn error code of service task. so i need to get bpmn error event in java delegate class. I just need to check if it exists.

sample process bellow

best regard…

find solotion this issue…

		catch(Exception ex) 
		{
			System.out.println("catch started");
			var ErrorCode = "GlobalError";
			
			var boun = execution.getProcessInstance().getBpmnModelInstance().getModelElementsByType(BoundaryEvent.class);
			for (var item : boun) 
				{
					System.out.println("attachto = " + item.getAttachedTo().getId());
					System.out.println("current ac id = " + execution.getCurrentActivityId());
					if(item.getAttachedTo().getId().equals(execution.getCurrentActivityId())) 
						{
							System.out.println("current ac id = " + execution.getCurrentActivityId());
							var definitions = item.getEventDefinitions();
							for(var def : definitions) 
								{
									if(def.getClass().getSimpleName().equals("ErrorEventDefinitionImpl"))
									{	
											
											ErrorCode = ((ErrorEventDefinition)def).getError().getErrorCode();
											System.out.println("TEXT CONTENT = >  " +((ErrorEventDefinition)def).getTextContent());
											System.out.println("RAWTEXT CONTENT = >  " +((ErrorEventDefinition)def).getRawTextContent());
											System.out.println("errorcode = >  " +((ErrorEventDefinition)def).getError().getErrorCode());
											System.out.println("ERROR CODE = >  " + ErrorCode);
											System.out.println("codevariable " + ((ErrorEventDefinition)def).getCamundaErrorCodeVariable());
											System.out.println("codevariable " + ((ErrorEventDefinition)def).getCamundaErrorMessageVariable());
											break;
									}
								}
						}
				}
			if(ErrorCode.equals("GlobalError")) {
				execution.setVariable("ErrorTaskId", execution.getCurrentActivityId());
			}	
			
			throw new BpmnError(ErrorCode, ex.getMessage());

Thank you @Rasim_Savas !