Flowchart inside Try-Catch

Is it possible to enclose a flowchart within a try sequence so if any part of the process fails the “catch” will be executed? This seems to work for sequences but not for flowcharts, in my testing here.

Thanks,
Paul.

1 Like

Yes, a flowchart within a try-catch will work fine. If yours isn’t currently working, you could upload the .xaml - i’d be happy to take a look to try and determine the cause

3 Likes

yah ofcourse it would work for sure
here you go with a sample image
image

Cheers @pduffy

Thanks Palaniyappan. I didn’t mean I can’t instantiate it, I mean it doesn’t work - it never executes the catch if there is a problem.

Hi Dave,

Thanks for your reply. I can’t share the source xaml that is giving me problems, but I managed to reproduce the error in the attached xaml. Oddly, when I reproduced in a different program it worked. Maybe something obvious I’m missing will jump out at you here :-/

Thanks,
Paul.Main.xaml (8.8 KB)

Can you show me a screenshot of the flowchart portion? Things like this almost always come down to a logic issue & having a second pair of eyes is invaluable. Do you have another developer on your team that could review it with you? If not & you can’t share even the screenshot, then try doing the “rubber duck” method and explain the entire process walking through it step by step out loud to yourself.

Please see my modified reply above with the error reproduced

Which dependencies/activity packs are being used? I tried opening it and got an “Unresolved activities” error. I am on 2018.4.3 still, so if it is using activity packs that are not backwards compatible up to that version then unfortunately it won’t work for me to open it up.

The activities packs loaded were not needed, so I’ve re-attached main.xaml with just these 2:

UiPath.System.Activities
UiPath.UiAutomation.Activities

Since I am using UiPath community edition, it is at version 2019.8.0
Main.xaml (8.8 KB)

UiPath.System.Activities - this activity pack needs to be version 19.4.1 or lower otherwise it won’t work with my studio
UiPath.UiAutomation.Activities - this activity pack needs to be version 19.4.2 or lower otherwise it won’t work with my studio

I’m guessing you’re using a later version for one or both of these activity packs. Could you change the activity packs to the versions mentioned (or lower)? Otherwise you’ll have to post a screenshot or wait for another person to take a look

Interestingly, when I revert to these earlier versions I also get an “unresolved activity” error on the try-catch block. Very strange…

The main.xaml file I attached has only a try-catch with a flowchart containing a single click activity inside it with a bad selector. This was to force the catch section to execute, which it didn’t. When I try to reproduce the problem in a new project, it actually works fine - so to reproduce the error I had to copy my original program and create the try-catch in there. I’m thinking of just re-creating the entire project in a new directory and copying over the blocks as much as possible… perhaps this one got corrupted.

Thanks a million for your help, I’ll let you know how it goes.

What is in your catch block? Is it catching system.exception? Or is it catching something more specific? What happens if you just use a throw activity as the first item in your flowchart?

Hi Dave,

The catch is a system.exception. In the main.xaml attached earlier, I purposely try to click a selector that won’t exist to force the catch to execute. Inside the catch is a simple message box displaying the word “Error”. I expect when the catch fails the error message will show, but it never executes.

FYI - in the larger program I am trying to use this approach to close some open applications if the program fails. I can’t use the Global Exception Handler sequence because it doesn’t give me access to variables within my ‘main’ program, so instead I am just trying to wrap everything into a try-catch block and let the catch section do the cleaning up.

Hey guys just FYI, I got it working by creating a new project with try-catch and copying across the blocks. I guess my other project got corrupted somehow, but the new one works fine.

Thanks for your replies! :slight_smile:

Cheers,

1 Like

Great
Cheers @pduffy

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