- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 07:50 AM
Hello,
What is the proper way to intentionally throw an error from within a workflow run script activity? I don't mean catching any random error with a try/catch block. I need to intentionally throw an error such as (throw "something broke"';). I have added the error condition to my activity, and I see that it is triggered when activity.state == 'faulted', but when I set activity.state to faulted using an if/else statement, the error condition/path is not used once the activity exits. I am trying to cancel the remainder of the workflow if a particular scenario occurs, but every attempt to throw an error or set the activity.state to faulted just continues down the 'good' path. Thank you for any help you can provide.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:05 AM
Use a try/catch to trap any error and then just set the result to error or failed or some such and add a custom branch to the workflow activity that looks for that and then connect that to the workflow end or what ever activity is next in your error branch.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:05 AM
Use a try/catch to trap any error and then just set the result to error or failed or some such and add a custom branch to the workflow activity that looks for that and then connect that to the workflow end or what ever activity is next in your error branch.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:15 AM
You can use throw to throw a custom error. in the run script you can use below
throw "500"; //replace 500 with your custom error.
Please mark this correct & helpful if it answered your question.
Thanks & Regards,
Sharjeel
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:46 AM
use below in your workflow script
try {
var et = new ErrorThrower(current);
et.throwAnError();
} catch (e) {
workflow.error('## Caught An Error ## ' + e);
}