Try-Catch not working

Hi all,

We have a project where the designed bot is intended to go to a website and scrape some data. We are using get text activity to scrape the data. The entire project is built using ReFramework. I have 3 Get Text activity within the workflow. I’m trying to use Try-Catch around this.

Scenario1:
When I run this workflow with Try-Catch bot still throws an error when selector for the Get Text activity is not found.

Scenario2:
If I use Try-Catch for each Get Text activity individually then the try-catch works. It catches the exception and finally part is executed.

Scenario3:
If copy the workflow to a different location out of that project folder than the try-catch works have all the 3 Get Text activity within the same Try-Catch.

Any thoughts on this.

Thanks,
Ashok

1 Like

Hi @ashoks93,

Are you running try catch in Debug mode?

No. I run the workflow and still throwing error.

Hi
–lets go one by one

So thes two are fine

But i would prefer the first one which is the correct method to add a try catch as a whole rather to individual get text activity
–kindly use SYSTEM.EXCEPTION in the exception dropdown in the catch block and try once, The reason is it will take all kind of common exception, that includes selector issue as well

–but make sure that using catch is not only to find the exception, we need to get back to the process from the beginning to be executed again. if it loses again then we can let the users that we got errored out
–so in the catch block if any exception occurs, use a log message in the beginning to help us debug whether we are in catch block or not by mentioning
"Process failed unfortunately at :" + Exception.Source + " due to the :" Exception.message

this will let us know the reason behind and at what activity we faced the error while debugging

and next to this place the complete sequence that we have in the try block so that it will try to execute the same process again from the beginning
–use kill process with required process names mentioned if needed

Kindly try that once and let know for any queries or clarification
Cheers @ashoks93

1 Like

Hi @Palaniyappan,

Thanks for taking time to examine the issue.

  • I have tried using SYSTEM.EXCEPTION but still it does not catch any exception. The workflow behaves as if no Try-Catch is used.

  • The workflow is not even going to the catch part as the bot exception is nor caught in the first place.

Please let me know if I need to try something else.

Thanks in advance!

Ashok

If possible can I have view in your xaml
Cheers @ashoks93

No unfortunately I can’t share the XAML file as it has sensitive data. But I will see if I can replicate the workflow with sample data but it will take some time.

Thanks,
Ashok

Strange… Are your Try Catch statement inside of any another sequence ~ workflow? Perhaps your code are runnning but is not reaching try catch point due some error before

1 Like

No it is not under any other try-catch sequence.

Try- Catch works if there is only one activity within the try part. But when I add more than 1 activity try catch fails to capture the exception.

Thanks,
Ashok

Adding + @ClaytonM @loginerror

Guys, any solution for this situation?

Thanks,
Ashok

Could you please share your xaml file?

Tks

1 Like

Make sure the ContinueOnError is not set to True or it will not capture it.

Just show some screenshots of your activity or properties. You don’t need to attach your XAML or anything if you can’t do that.

Regards.

I just replicated the situation in following XAML file.

I have kept the the other files in this project folder to replicate what I use. Please run the process xaml file to test.

The message box accepts Int. When you provide string value as input it throws error. This error is handled in Try-Catch1 but fails in Try-Catch2.

Thanks,
Ashok

ScrapingBot.zip (502.1 KB)

1 Like

Thanks for your response @ClaytonM !

ContinueOnError is not set as true.

I have replicated the issue and uploaded the xaml file in my previous reply.

Ashok

Hello, first I’d like to point out that my question about sharing files was not with reference or mandatory ordering, being optional sharing (according to the forum rule that is very clear and accessible to everyone, in addition to what Clayton Claimed). This was only so that other contributors to the forum besides Clayton, could also have a clearer view of the need and help you, anyway I’m glad you understood =).

Second, I gave an edited and tested your Reframework XAML using the 2 try catch in Process and worked perfectly (assigns a log with the exception) and also created a BusinessRuleException only.

I’m attaching the last file I’ve tested ~ edited, take a look and see if the try catch are performed (enter strings in the input boxes)
ProcessCHANGEDKOTINDA.xaml (12.6 KB)

1 Like

Thanks the xaml file @Felipe_Kotinda! Can you please compress and upload the entire project as I sent you. As I previously mentioned If we copy the process.xaml file to a different folder and execute it is executing as expected but if we are executing it within the project then try catch stops working.

Thanks,
Ashok

Ohh sorry, follow attached here (I changed again the name to standard -> Process)

If it’s still doesn’t work, tell me So I can try to figure out what’s going on

Check the output with logs after robot execution (I added a message for when bot reaches catches)

ScrapingBot.zip (502.4 KB)

Thank you!

It’s still not working. Please find the project attached. When try catch has more than 1 activity it fails.

image

Thanks,
Ashok

ScrapingBot.zip (502.4 KB)

:confused:

I tried again here (based the last file you sent me and the file attached here) and it works, I`ll check better and get back for you asap

ScrapingBot.zip (502.4 KB)

Please find the screenshot of the error message thrown!

Thanks,
Ashok