Continue "for each" loop After Exception

I have a for each loop, and would like to instruct it to continue to the next record, if an exception arises. There are approximately 65+ sub-activities in the loop, which I have packaged into “Main Sequence”. I put that Main Sequence into a Try Catch under Try, and then specified the most common exception (NodeNotFound) in Catches, with an activity of Continue for that catch. I also put Continue under Finally. See screenshot below.

When I run the workflow, it still presents an error screen with each exception, rather than moving to the next row.

Am I supposed to package the entire “For Each” activity into Try?

Any ideas would be appreciated!

@jon4378

execute the project in "Run project" mode.

Thank you. I have “Run” and “Run File”. Did you mean Run File?

Anyway, I have tried both, and am still getting error screen.

Screen Shot 2022-06-18 at 10.56.38 AM

@jon4378

The last one or you also use "ctrl+f5" for execution.

Yes, I tried both, including “Run” and I still get a popup error screen when it has a NodeNotFound Exception. Hmmm.

@jon4378

Can you share the screenshot of the error.

Hi @jon4378,

You can manage exception by setting system exception instead of NodeNotFound in catch field and adding condition in it

Regards,
MY

Thank you @muhammedyuzuak. I included system exception instead of the nodenotfound exception, and still get an error popup. I was not sure what you meant by “adding condition in it” though. See screenshot below.

And @Vaibhav_Rajpoot_17, I have included screenshots of the errors below as well.

Any ideas @muhammedyuzuak or @Vaibhav_Rajpoot_17 ? Thank you in advance!

What happens if you simply log the error or do nothing instead of using Continue? Swallow the exception.

Thank you. I tried doing what you suggested (leaving the activity blank under the exception), and also tried replacing continue with a message box. I still just get the normal error screen, with a nodenotfound exception. Screenshots below.

Question: Does it matter how many levels of nested sequences within sequences I place in the Try block? I may have as many as 4-5 levels of nesting within that “Main Sequence”.

Thanks again for your help!

Levels shouldn’t matter. Try using a normal exception instead of nodeNotFound just to confirm it will trap any/all exceptions.

If you can trap it as a normal exception, maybe you can interrogate the type in there and ignore.

I don’t often use specific exception types so I can’t personally speak to how reliable they are.

@jon4378

can you re validate the selector for this specific element.

Thank you. When you say “normal exception”, do you mean “system exception”? If so, I have tried that (see above) to no effect. Hmmm.

Yes, re-validated. But may I ask how that relates to the exception not being caught?

I just combined two of your suggestions, just for the heck of it:

  • System Exception (assuming that is what you mean as “normal”)
  • With no activity (“swallowed”)

No change - still get an error screen.

So just to confirm… are you running in debug mode, or normal play mode?

I vaguely recall that exceptions ALWAYS present a dialog when I’m debug mode, but function as expected in normal play mode.

These days I rarely use debug mode.

Edit:

Oh I see above you do talk about run mode.

Well I am stumped. I use a try/catch inside my loops all the time and never have issues like this.

Hi @jon4378,

In the example below I throw a throw for index = 1 and persist it in the catch field. Can you compare it with your work?

image

simpleExample2.xaml (10.2 KB)

In addition, can you share the exact moment you receive the exception (red box)? If the loop gives an error before it even goes inside, these operations are meaningless.

Regards,
MY

1 Like

Thank you. I tried your test and yes, it worked fine. The process continued even after the throw for index=1.

To answer your question, the error/box appears only after the process enters the loop, not before.

Unfortunately, mine is still not working.

I don’t think this would make a difference, but the way I am getting the app to error out, is by moving the scroll bar in chrome, so that the app cannot find the UI element. It is just a simple scroll, and then a few seconds later I get the error. I don’t think that would make a difference though, it should just continue on no matter how or why the error happens.

Hi again @muhammedyuzuak . I just found something interesting. The other day when I ran your example test, the try/catch/continue worked as expected. But today i opened your same example as a separate file/workflow within my main project, and I received an error screen, indicating that the try/catch did not work. So it must be some kind of setting or design issue within my main project, that is preventing the try/catch from working correctly? I did try resetting all of my Studio settings, but it did not make a difference. Any ideas would be much appreciated!