I am using Camunda Platform more and more for my Node/Express application, and I enjoy it more and more! Thanks btw for the help provided on this forum!
I would like to let users (who model workflows, and let them run in the background thanks to Camunda) have access to some reporting and notifications (email) when errors occur. It could be for instance:
- errors during execution, which are in most cases thrown by
taskService.handleBpmnError from the
camunda-external-task-client-js npm package.
I have read the “error handling” section of the user guide, but I am a bit confused on the best approach I should take. Would you please have some guidelines, or a link to some further documentation/tutorial that could help? (on of my needs would be if I want to notify by email when an error occurs).
Also, I would like to report the error messages produced by Camunda, but with the opportunity to “simplify” them a bit. For instance, by removing all the Java-language related stuff (e.g. stack trace). Ideally, I would like to be able to relay on error codes, and object IDs (such as activity IDs where the error occurred) to present a business-friendly message - possibly translated to languages other than English (Spanish, French, …). It looks to me that the error messages are kind of hard-coded, which would make this task difficult, if not impossible, but maybe I have missed something?
Many thanks for your help on any of these 2 questions!
Unfortunately no help so far, but I could make some progresses by myself, which I am happy to share here.
- Errors due to syntax errors in script tasks: it looks like 2 cases may happen:
1.a) if the error occurs in a task which is “directly” linked to the Start event (e.g. no timer in between), then it can be retrieved from the
/process-definition/id/start API as a 500 error status, with a message like:
Cannot instantiate process definition process-12:8:624beaf8-4661-11ec-b7c8-0242ac110002: Unable to evaluate script while executing activity 'Event_1ydqfuy' in the process definition with id 'process-12:8:614beaf8-4661-11ec-b7c8-0242ac110002':org.graalvm.polyglot.PolyglotException: ReferenceError: sdfgdfsdfg is not defined
1.b) if the error occurs later (e.g. after a timer has ellapsed, following the Start event), then the Camunda console logs an exception:
javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: ReferenceError: sdfgdfsdfg is not defined
incident is created:
Unable to evaluate script while executing activity 'Event_1ydqfuy' in the process definition with id 'process-12:8:614beaf8-4661-11ec-b7c8-0242ac110002':org.graalvm.polyglot.PolyglotException: ReferenceError: sdfgdfsdfg is not defined
- Errors occurring in external tasks (in Node/Express): then
retries=0 causes an
incident to be created, which can then be accessed from the REST API and reported to the user.
All this said, I can reformulate my question more accurately:
For 1.a) and 1.b) : is there a clean way to parse this error message to extract the relevant information to build a user-friendly message (especially: without the Java exception class)?
What happens when an error occurs in a process instance launched by a signal (this should be a case 1.c) and how to handle the error in that case?
Hey @bfredo123 ,
The behavior where an error occurs (return 500 from a start REST call or later in the Camunda console) is based on the transaction behavior of Camunda. When an error occurs Camunda always rolls back to the last transaction point and the error is displayed there. I think it can be worth looking at the transaction boundaries and how you can set them in the model if you need some.
If missing variables causes errors, it could be a solution to define input and output mapping for your variables for certain tasks.
I am not sure about your last question. Do you mean a Signal BPMN event? If the signal starts a process instance in general the error handling remains the same. Maybe you can elaborate on that a little and I can see if I can help.
Hope this already helps. Cheers
Thank you so much for this answer. I have learnt a lot about “transaction boundaries”!
About parsing the error messages, I fear that it is not robust, because if they are rephrased in a future version of Camunda, then the parsing could fail. And also, I don’t know the comprehensive list of potential messages to handle. Maybe this is a wrong assumption though.
/signal REST API. As this method returns nothing, I don’t know which process instance(s) are created from the signal, and then I don’t know how to link the potential exception to the instances. By reading the doc about transactions, maybe the solution would be that I make the signal event “asynchronous after/before”, and then an incident would be created in case of such an exception? I will try that.
Why are you not using a messenger instead of a signal? The implementation of the signal is accordingly to the BPMN standard from the OMG. A signal can trigger multiple process instances without knowing which ones are triggered. I think the async after/before will not solve this problem and might make it even more complex.
Unfortunately I am not a JS expert but I am sure you will find something within their community.
Thank you Nele!
Actually I would like to offer the capability that any user-made process is triggered when a specific event happens (e.g. a new business object is created on the server, and one user would like to process 1, 2, 3, or more processes when this occurs). So I thought signals were the way to go, preferably to messages.
Other ideas welcome!