Changing the type of Exception thrown by Camunda

hello everyone,
I have a method that is called during a process by camunda.
I have put a mechanism in this method to show the appropriate error message to the user if an error occurs.
But when this method hits an error, instead of displaying my proper error message, it throws this error message:
Transaction silently rolled back because it has been marked as rollback-only
In fact, camunda converts my type of error, which is a RuntimeException, to UnexpectedRollbackException.

Does anyone have an idea to solve this problem?

Hi @Ali_Kheiri ,

from my understanding any uncatched exception will lead to Camunda attempting a rollback. While I would recommend against changing this behaviour, I do not think, this is possible. What you could do instead would be to catch your user-defined exception and raise a bpmn error. Maybe the following documentation helps you on this:

Kind regards

1 Like

@Adagatiya Thank you for your guidance
I don’t want to prevent camunda rollback.
I want to inform the user about the reason why camunda has hit the exception using the appropriate exception message, but Camunda destroys my exception.

Hi @Ali_Kheiri,

Did you try throwing a org.camunda.bpm.engine.ProcessEngineException as follows:

throw new org.camunda.bpm.engine.ProcessEngineException("My Custom Error");

Kindly find a simple running example containing the above throwing statement as a script
test_acid_trans.bpmn (3.1 KB)