# Trigger Error event using API

**URL:** <https://forum.flowable.org/t/trigger-error-event-using-api/5956>\
**Category:** Flowable Engine\
**Created:** [May 5, 2020, 5:17am UTC](https://forum.flowable.org/t/trigger-error-event-using-api/5956 "2020-05-05T05:17:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joyal.joy777](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joyal.joy777/32/1791_2.png) [@joyal.joy777](https://forum.flowable.org/u/joyal.joy777)\
**Post date:** [May 5, 2020, 5:17am UTC](https://forum.flowable.org/t/trigger-error-event-using-api/5956/1 "2020-05-05T05:17:41Z")

</div>

Hi guys,

I am trying to make a bpmn model where we have used a boundary error event which will be assumed to trigger on failing a REST call or exception occurred from a REST call.

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

I am curious that whether an error event can be trigger like a signal event(which can be done using code:- runtimeService.signalEventReceivedAsync(signal, execution.getId()) ). Similarly can I trigger an error event using any api while the current execution is on a user task. or how should I properly throw a BpmnError from a user task.

Regards,  
Joyal Joy

---

<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:** [May 6, 2020, 8:33am UTC](https://forum.flowable.org/t/trigger-error-event-using-api/5956/2 "2020-05-06T08:33:05Z")

</div>

Hey @joyal.joy777,

You cannot trigger a bpmn error through the public API.

Why don’t you use a Signal Boundary event instead of an Error boundary event?

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![joyal.joy777](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joyal.joy777/32/1791_2.png) [@joyal.joy777](https://forum.flowable.org/u/joyal.joy777)\
**Post date:** [May 6, 2020, 8:43am UTC](https://forum.flowable.org/t/trigger-error-event-using-api/5956/3 "2020-05-06T08:43:09Z")

</div>

Hi @filiphr,

Thanks for the reply.

So the context is more related with dealing an error which occurred in the middle of an active task. For example I am doing a user task which in turn calls a rest service via an event listener which leads to error(could be a n/w failure, server failure or some exception). So I want to consider the situation while modeling. So an error event make more sense than a signal event. Can I throw a **BpmnError** somehow in the active task?

---

<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:** [May 6, 2020, 8:59am UTC](https://forum.flowable.org/t/trigger-error-event-using-api/5956/4 "2020-05-06T08:59:51Z")

</div>

Hey @joyal.joy777,

OK it makes sense now.

What kind of event listener. Is it happening after the task is being completed (in which case you can’t throw a BPMN error, nor a signal). You’ll have to do that with a service task. Otherwise I’ll advise you to have a look at `ErrorThrowingEventListener` and do something similar in your event listener as well
