Closed mrpotato3 closed 9 months ago
You should use bound error event to catch an error and take appropriate action.
Hi @paed01, thanks for responding so quickly.
This is a technical error, not business error. For example, it occurs before doing a wait
on the activity
when going to execute a REST service. Also, what happens (even if you put a "boundary error event") is that it breaks the process and ends execution on the server.
I perform the actions in an extension during the activity.wait
event and when an error occurs I do a throw new Error('Custom error')
Example code:
activity.on('wait', async(element: any) => {
// REST request...
if (!restSuccess) {
throw new Error(`No signature flow template found.`)
}
// DO SOMETHING
})
Error in the process:
Error: Custom error thrown.
at handleExecuteREST
at handleProcessActivityWait
at Consumer.eventCallback [as onMessage]
at Consumer.consume [as _consume]
at Consumer.push [as _push]
at Queue.consumeNext [as _consumeNext]
at Queue.queueMessage
at ExchangeBase.publishToQueue [as _publishToQueue]
at ExchangeBase.topic [as _onTopicMessage]
Thanks!
You could use the, unfortunately undocumented, element.fail(new Error('Custom error'))
function to make the user task fail.
Sounds like a nice undocumented feature :) How and where can you use element.fail(new Error('Custom error'))
@paed01 ?
@paed01 perfect! thanks.
What is the correct way to handle errors? I have a UserTask that in the "wait" event performs asynchronous operations that can fail. If I handle the error via "new Error("Error message") the process aborts with an unhandled error exception. Good job and thank you very much!