# BpmnError context in ErrorBoundaryEvent

**URL:** <https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762>\
**Category:** Flowable Engine\
**Created:** [July 24, 2017, 8:42am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762 "2017-07-24T08:42:17Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrej\_Zirko](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/andrej_zirko/32/209_2.png) [@Andrej\_Zirko](https://forum.flowable.org/u/Andrej_Zirko)\
**Post date:** [July 24, 2017, 8:42am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/1 "2017-07-24T08:42:17Z")

</div>

Hello,  
We would like to model a generic error handling for BPMN errors. Each of our tasks can throw BPMN error with different error code and error message. Then we would like to have generic boundary error event, which catches all BPMN errors (without filled errorCode).

Our boundary event successfully catches all error code. Unfortunately we haven’t found a way how to access the BPMN error context in error handling.

How can we get the error code and error message that we caught in error handling? We try to avoid having numerous specific boundary error events, so we can keep the error handling generic.

Thank you,  
Andrej

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [July 25, 2017, 2:51pm UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/2 "2017-07-25T14:51:29Z")

</div>

Afaics in the code, that’s currently not possible. A boundary event without error code will catch any error … but that information is lost once the boundary event is triggered (here: [https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorPropagation.java#L234](https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorPropagation.java#L234))

I like the use case, it’s a useful thing to have 🙂

I guess the most flexible way would be to store the errorId (the errorCode can be looked up from the BpmnModel) in a variable?

That would need some extra attributed on the errorEventDefinition which normally is defined like

```
<boundaryEvent ... >
  <errorEventDefinition errorRef="errorId" />
</boundaryEvent> 

```

like

- storeErrorVariable (by default false, for backwards compatibility)
- errorVariableName (by default it would use the id of the eventDefinition or parent construct and adding .errorId or something
- errorVariableTransient (by default true, as it’s probably going to be used in an exclusive gw after the event)
- errorVariableScope (local or global, for setting is execution local or not)

wdyt? Would that cover your use case?

---

<div class="post-metadata">

**Author:** ![Zomzog](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/zomzog/32/344_2.png) [@Zomzog](https://forum.flowable.org/u/Zomzog)\
**Post date:** [October 3, 2017, 9:43am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/3 "2017-10-03T09:43:23Z")

</div>

Hello,  
We are facing the same problem, and yes this solution can cover our use case

There is no workaround ?

Thanks

---

<div class="post-metadata">

**Author:** ![PeterCahn](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@PeterCahn](https://forum.flowable.org/u/PeterCahn)\
**Post date:** [August 24, 2018, 12:58pm UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/4 "2018-08-24T12:58:11Z")

</div>

Hello, I’m sorry to take up this old conversation, but is there something new about this aspect? Someone has provided some workaround for it?

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [August 28, 2018, 11:17am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/5 "2018-08-28T11:17:24Z")

</div>

Hi,

No this is not implemented yet.  
The workaround for now would be to override the default error boundary event behaviour class. If it’s needed by more users then we can definitely raise the priority of this. It would already help to create a Github issue so we can discuss it a bit more and track progress.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![PeterCahn](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@PeterCahn](https://forum.flowable.org/u/PeterCahn)\
**Post date:** [August 28, 2018, 3:48pm UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/6 "2018-08-28T15:48:45Z")

</div>

I see.  
Just for my own understanding, do you think it is tricky the implementation which enables the error context to pass through the boundary event or is there another motivation to avoid the bpmn error propagation?

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [August 31, 2018, 6:39am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/7 "2018-08-31T06:39:15Z")

</div>

Hi,

No, I don’t think the implementation of passing the error context should be tricky. It’s a good feature for the Flowable Engine and definitely makes working with BPMN errors more powerful.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![bpran](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@bpran](https://forum.flowable.org/u/bpran)\
**Post date:** [March 26, 2021, 10:15am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/8 "2021-03-26T10:15:16Z")

</div>

Hi,  
I am more than interested to see this feature implemented. It would really make error handling a lot easier.  
So, I’m wondering if I can create a github issue and offer my contribution by implementing it as @joram proposed?

Best regards,  
Boris

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [March 29, 2021, 9:00am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/9 "2021-03-29T09:00:18Z")

</div>

Hey @bpran,

> [@bpran](#):
>
> So, I’m wondering if I can create a github issue and offer my contribution by implementing it as @joram proposed?

We are always happy to receive contributions from the community. You don’t have to create an issue though. You can work on an implementation and then open a PR where we can talk about it.

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![bpran](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@bpran](https://forum.flowable.org/u/bpran)\
**Post date:** [March 29, 2021, 9:29am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/10 "2021-03-29T09:29:50Z")

</div>

Ok. Thanks. Will do that!

Best Regards  
Boris

---

<div class="post-metadata">

**Author:** ![ariz.raza](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@ariz.raza](https://forum.flowable.org/u/ariz.raza)\
**Post date:** [May 12, 2022, 12:13pm UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/11 "2022-05-12T12:13:43Z")

</div>

Hello,  
We has this feature been implemented, we would like to use the error context in bnmperror to build our error workflow from generic exceptions

Regards,  
ariz

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [May 16, 2022, 4:08pm UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/12 "2022-05-16T16:08:10Z")

</div>

No, it hasn’t been implemented. It’s still would be a very nice feature to have … 🙂

---

<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:** [August 26, 2022, 7:20am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/13 "2022-08-26T07:20:04Z")

</div>

Seems like this has been worked on, at least partly:

> <https://github.com/flowable/flowable-engine/pull/2884>
>
> Motive for this feature is to enable generic BPMN error handling without the nee…d to know in workflow design-time which error code will be thrown. 
> 
> ErrorEventDefinition gets three new properties:
> \- String errorVariableName, name of the variable containing error code, default null
> \- Boolean errorVariableTransient, whether variable should be transient, default true
> \- Boolean errorVariableLocalScope, whether variable should be stored in local scope, default true
> 
> If errorVariableName is not set nothing gets injected, this way backward compatibility is maintained, else, error code is stored into named variable. Scope and transience depends on flags.
> 
> Unit testing and documentation is missing since these are just proposed changes.

Leaving this as a reference here, as I find the use case interesting and valuable too.

Edit:  
Verified it works with a simple model:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/5/5bf187412921c216ed2952f67e031d580592ef5d.jpeg)

Test Case passes

The startEvent of the eventSubProcess just needs the attribute to store the BPMN Error code in a variable:

```auto

 <startEvent id="startErrorEvent1" isInterrupting="true">
        <errorEventDefinition flowable:errorVariableName="error_code"></errorEventDefinition>
 </startEvent>

```

There are also `flowable:errorVariableTransient="true|false"` and `flowable:errorVariableLocalScope="true|false"`attributes available.

---

<div class="post-metadata">

**Author:** ![remibantos](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/remibantos/32/504_2.png) [@remibantos](https://forum.flowable.org/u/remibantos)\
**Post date:** [September 12, 2023, 7:02am UTC](https://forum.flowable.org/t/bpmnerror-context-in-errorboundaryevent/762/14 "2023-09-12T07:02:11Z")

</div>

Hello,

Could this be added to Flowable documentation here please?

> **[BPMN 2.0 Constructs · Flowable Open Source Documentation](https://www.flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs)**
>
> This chapter covers the BPMN 20 constructs supported by Flowable, as well as custom extensions to the BPMN standard.

Thanks,  
Rémi
