For each loop in try catch

I have a for each loop to run all rows of my data. And now I know there are two exceptions(not going to pass to next row, depends on the exception, there are different flows to move on) that will happen in some of the rows. I am thinking to use try catch activity but I am not quite sure it’s right or not.

For example:

[For each loop]
[Two exceptions]
[If exception 1 happens, then do to the sequence 1]
[if exception 2 happens, then do to the sequence 2]

Is this workable? I am not sure after dealing with the exception of one row, can it move on to the next row (in the for each loop)??
Sorry I am a beginner so it may be a stupid question, thanks a lot!

Hai @JayLi… Yeah I think it’s possible only…In Finally block use if condition for ur 2 conditions… One more thing No matter its working or not… Let’s have a good try…:wink:

Hi @JayLi,

It is not going to move to the next row the way you have it, you will need to have the try catch inside the loop so it can catch it decide what to do and move to the next row without exiting, let me know if you more questions

If you know the exception type then use Them in Catch block:
Say 1 st exception is NullReferenceException then in that you can do the flow u want to do for that exception
similarly for second …
This will use for that row only after executing catch block it will start the next row.

Here I know i will get exception as System.Aggregate as Data has no value

So i have created catch block for that exception and use next flow for that exception

Similarly u can add next exception say System.Exception


1 Like