Hi, we have an http connector with an inline script to process the response:
var response = connector.getVariable(“response”);
var statusCode = connector.getVariable(“statusCode”);
if (statusCode != 200) {
throw new Error(connector.getVariable(“response”));
}
else {
JSON.parse(response).value;
}
If the statusCode is not 200 this results in an incident and the workflow stops, which is what we want. However there is a lot of information logged in via a ScriptEvaluationException that is very verbose and not really needed.
Look at the delegate execution API and the comments further down in the mentioned forum post: the execution.createIncident() method replaced the need to use the internal API.
I’m a bit confused by this comment “Look at the delegate execution API and the comments further down in the mentioned forum post: the execution.createIncident() method replaced the need to use the internal API.” Is there another way we can invoke " execution.createIncident()" in the http-connector’s scope?
Do you have an example on how to setup the execution listener (checking if server error status code then creating incident) with the http-connector?
I have the following configuration just to check if an incident gets created but the process just moves on and the incident is never visible in the cockpit.
@StephenOTT I have found your post stating that execution.createIncident() is non-blocking.
So I tried to throw an exception with JavaScript:
throw new Exception();
Then I got the error message:
Unable to evaluate script while executing..
When I used throw new java.lang.Exception(“exception message”); I got the message:
Unable to evaluate script while executing activity 'X' in the process definition with id 'X':<eval>:1:30 Expected an operand but found error throw new java.lang.Exception(“exception message”); ^ in <eval> at line number 1 at column number 30
First of all how I can throw an exception in a script task (just to test it) and what exceptions can be thrown?
I tried your example but unfortunately it didn’t work. I even created a new process with only a script task and it still gives me the following error message:
Unable to evaluate script while executing activity 'Task_0k44fns' in the process definition with id 'IncidientExample:1:d31f7ba8-3064-11ea-90fb-005056031c08':org.camunda.bpm.engine.ScriptEvaluationException: Incident happened in <eval> at line number 1 at column number 0
here is the created process and the script task configuration: