# Throwing a BpmnError in my custom code not being caught by error boundary event

**URL:** <https://forum.flowable.org/t/throwing-a-bpmnerror-in-my-custom-code-not-being-caught-by-error-boundary-event/12466>\
**Category:** Flowable Engine\
**Created:** [November 3, 2025, 8:30pm UTC](https://forum.flowable.org/t/throwing-a-bpmnerror-in-my-custom-code-not-being-caught-by-error-boundary-event/12466 "2025-11-03T20:30:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chelsea.reynolds.ok](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@chelsea.reynolds.ok](https://forum.flowable.org/u/chelsea.reynolds.ok)\
**Post date:** [November 3, 2025, 8:30pm UTC](https://forum.flowable.org/t/throwing-a-bpmnerror-in-my-custom-code-not-being-caught-by-error-boundary-event/12466/1 "2025-11-03T20:30:59Z")

</div>

I created a BPMN process, and it has one callActivity. The job of the callActivity (custom service task) is to send an email. I need to resolve recipients of the email, and I do this on the parent process, and then pass that resolved variable into my send email callActivity. To resolve recipients, I’ve implemented custom logic so that I can call a custom method to populate the recipients variable. This custom method is made available to the flowable engine runtime via the spring application context (as a Spring Bean - NOT a JavaDelegate). I use a Spring @configuration class to define a handful of singleton beans.

My custom logic is implemented in a bpmn.xml process document like so: see bottom screenshot.

Notice in the sourceExpression, my bean’s name is email and my custom method is called testBpmnError(). This method throws a BpmnError.

My [overall goal](https://www.flowable.com/blog/engineering/streamlining-error-handling) here is to implement error handling so that when there are errors in my custom code, I can throw them as BpmnErrors, which can be handled in the bpmn processes via boundary events, and I can do something with those errors in my process.

The problem I am having is that when I throw a BpmnError from my custom logic, it comes back as a FlowableException (with root cause being my BpmnError), and the whole transaction rolls back and stops my process in its tracks. The boundary event does not catch the FlowableException.

Is anyone familiar with error handling exceptions in custom code? Ultimately, I want to propagate my errors and do things with them, not shut down my process and roll back the transaction.

I’m a Flowable newb, so I may be missing some foundational knowledge though I have been combing through docs. Here’s my full bpmn process document for reference:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/a/a1bfdcec97476d1ac95a598adc71e424b46b2142.png)

---

<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:** [November 4, 2025, 9:40am UTC](https://forum.flowable.org/t/throwing-a-bpmnerror-in-my-custom-code-not-being-caught-by-error-boundary-event/12466/2 "2025-11-04T09:40:13Z")

</div>

Hey @chelsea.reynolds.ok,

As you are explaining this, things should work. Can you perhaps share a minimal reproducible repo with the code and your model?

By the way in your BPMN process at the end you have an error end event. That error end event will not catch all errors, since that one is not for catching, but it’s for throwing one, i.e. the process ends with throwing a BPMN Error.

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![chelsea.reynolds.ok](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@chelsea.reynolds.ok](https://forum.flowable.org/u/chelsea.reynolds.ok)\
**Post date:** [November 5, 2025, 4:30pm UTC](https://forum.flowable.org/t/throwing-a-bpmnerror-in-my-custom-code-not-being-caught-by-error-boundary-event/12466/3 "2025-11-05T16:30:48Z")

</div>

Filip,

Thank you for the fast reply! Here is a public repo where the unit test can replicate the question scenario.

> **[flowableQuestion/src/main/java/org/example/bugdemo at main ·...](https://github.com/chelsea1994/flowableQuestion/tree/main/src/main/java/org/example/bugdemo)**
>
> Having issues in custom java logic throwing and catching/handling BpmnError inside bpmn process - chelsea1994/flowableQuestion

---

<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:** [November 5, 2025, 7:50pm UTC](https://forum.flowable.org/t/throwing-a-bpmnerror-in-my-custom-code-not-being-caught-by-error-boundary-event/12466/4 "2025-11-05T19:50:28Z")

</div>

Thanks @chelsea.reynolds.ok,

I think I see the problem now better. You have

```xml
<flowable:in sourceExpression="${customBean.testBpmnError(execution, true)}" target="testString"/>

```

i.e. you are throwing an error in the `sourceExpression`. This does not work, since this is not a place where we are expecting a business error. You should test it by either throwing that error in the `callActivity.bpmn20.xml` or use a Service Task with that expression.

Cheers,  
Filip
