How to throw exception then continue

I am stuck on executing rest of code after throwing exception. Basically, I am using Element exists activity with the “Try” block of a try/catch activity to determine if user’s entry was found in combobox. The next activity in the sequence is an IF activity which throws BusinessRuleException if the value from Element exists is false, else it selects the element. In the catch block of the try/catch, I am catching BusinessRuleException.
The issue is, execution stops at the “Throw” activity, so, the catch block never executes.
What I am trying to achieve is, throw exception then catch it in the catch block to handle other business logic.

2 Likes

Hi @dari_donkuro,

Are you using REFramework? If so, notice that even if you use a throw in the catch block, the BRE has been lauched and the natural flow of REFramework is to go to GetTransaction.

If you are nothing using REFramework this occurs because you do not have a treatment to handle BRE, so the process has to end. Some actions you might take includes:

  • As long as you are using try/catch, you could treat your exception in the catch block without the need of using Throw activity.

  • If you want to use Throw activity make sure that your process handles any BRE. You could consider create a State machine or using REFramework (that is a state machine with some error handling already mapped).

Hope this helps =)

2 Likes

Hi @dari_donkuro

Only if you put Throw activity in Try block, the throwed exception will be catched and the Catch block will be executed.

3 Likes

@Schirru I resolved the issue. But i’m not satisfied. If I publish the workflow to Desktop Agent, it behaves properly. But if I run the workflow from the studio, it breaks at the throw activity, where I can step into, then continue, for it to follow normal path. I just want it to go ahead to finish remain code.
Thanks,

@dari_donkuro, How do you run workflow? Using Debug or “Run” menu? It seems like you are running workflow in debug mode. If you execute workflow using “Run” option it won’t break. It’s default and intended behavior.

Cheers

6 Likes

As @Bhavik_Solanki mentioned, probably you are executing your process in Debug mode. When you run in Debug mode all the activities related to erros will display a popup message, if you click in continue button the process should continue the normal path if you treat this erros.

If you don’t want to see the pop ups, just choose “Run” mode in Design tab.

4 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.