# Error handling in flowable BPMN process

**URL:** <https://forum.flowable.org/t/error-handling-in-flowable-bpmn-process/9583>\
**Category:** Flowable Engine\
**Created:** [July 29, 2022, 6:04am UTC](https://forum.flowable.org/t/error-handling-in-flowable-bpmn-process/9583 "2022-07-29T06:04:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasanta](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/prasanta/32/2864_2.png) [@prasanta](https://forum.flowable.org/u/prasanta)\
**Post date:** [July 29, 2022, 6:04am UTC](https://forum.flowable.org/t/error-handling-in-flowable-bpmn-process/9583/1 "2022-07-29T06:04:03Z")

</div>

Hi,  
Currently I am working on to implement BpmnError handling using error boundary event.  
What I observed is that flowable does not support catching exception, thrown as BpmnError from service task’s start/end executionListener. If exception is thrown from service task’s delegate class, then error boundary event can catch.

How can I achieve the error handling in this scenario.

Thanks,  
Prasanta

---

<div class="post-metadata">

**Author:** ![gdharley](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/gdharley/32/2695_2.png) [@gdharley](https://forum.flowable.org/u/gdharley)\
**Post date:** [August 1, 2022, 8:41pm UTC](https://forum.flowable.org/t/error-handling-in-flowable-bpmn-process/9583/2 "2022-08-01T20:41:30Z")

</div>

You are correct, BpmnError cannot be thrown from ExecutionListeners.  
Likely the best thing you can do is catch the exception, create a transient variable and test for this in your Service Delegate. If there was an exception, throw the BpmnError from the delegate.

It’s a little harder for the End event since the Delegate has already been processed. You could again set a variable and use a gateway after the task to test the error and handle.

Obviously not ideal.

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [August 2, 2022, 8:03am UTC](https://forum.flowable.org/t/error-handling-in-flowable-bpmn-process/9583/3 "2022-08-02T08:03:36Z")

</div>

I would prefer to change ActivityBehavior to support BpmnError handlling.

something similar as:

> <https://github.com/flowable/flowable-engine/issues/3094>
>
> \*\*Description:\*\*
> When triggerable service task throws BpmnError during the trig…ger execution, the exception is not handled by any event subprocess.
> 
> \*\*Expected behavior\*\*
> When BpmnError is thrown in the trigger method of the triggerable service task, any event subprocess can handle error.
> 
> \*\*Code\*\*
> https://github.com/martin-grofcik/flowable-engine/commit/27d6f23d422c0c728546f36c9b86465915baf56f
> https://github.com/martin-grofcik/flowable-engine/tree/%233094\_triggerableBpmnError
> 
> The proposed solution (jUnit test covers only one case) is to add try/catch blocks to all trigger calls.

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![arthware](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/arthware/32/2869_2.png) [@arthware](https://forum.flowable.org/u/arthware)\
**Post date:** [October 11, 2022, 7:41am UTC](https://forum.flowable.org/t/error-handling-in-flowable-bpmn-process/9583/4 "2022-10-11T07:41:39Z")

</div>

@prasanta @gdharley  
FYI: Support for throwing BpmnError from Execution Listeners is soon going to be merged and released with Flowable 6.8.0: [#3452 Support throwing BPMNError from executionListeners by arthware · Pull Request #3481 · flowable/flowable-engine · GitHub](https://github.com/flowable/flowable-engine/pull/3481)

Edit:  
PR has been merged to main. BpmnErrors thrown from Execution Listeners are now propagated in the model. Please read the doc snippet: [#3452 Support throwing BPMNError from executionListeners (docs) · flowable/flowable-engine@bf4cc43 · GitHub](https://github.com/flowable/flowable-engine/commit/bf4cc435bb6a3e5abfbb3858140d01b9ad1c1a9f)
