Catching exception/BPM-Error from script task


I’m trying to throw a BPM Error from a JavaScript task and catch it via a boundary event - unfortunately it doesn’t get caught.

I used the BPM Model below (and fixed the quotation marks) - so, I thought, I should be good but the process doesn’t enter either of the two user tasks. The process gets startet and disappears. (Unfortunately I don’t have access to the log files.) Any idea what could be wrong? Thanks, M.

BTW: Is there a better way to handle a technical error from within a script task than using BPM Errors? (How can I notify the process of an exception that was thrown within a JavaScript Task?)

Throwing BPMN Error in script task - javascript - Process Engine - Camunda Platform Forum

sure :slight_smile:

bpmn_error_event_example (2).bpmn (7.5 KB)

Hi @ArtVandelay101,

If errorRef of error event definition is specified then the thrown BpmnError should refer to the same error.

  • If errorRef is omitted, the subprocess will start for every error event that occurs.

so replace below throw statement
throw new org.camunda.bpm.engine.delegate.BpmnError("Error Message");
with the following
throw new org.camunda.bpm.engine.delegate.BpmnError("example-error-code");

Below is the constructor of BpmnError
BpmnError(String errorCode)

Thank you! I see, my mistake was to assume that the parameter of BpmnError() is the error message, when in fact, it’s the error code.

1 Like