Just trying to understand how to use exceptions within For each loops.
My Problem:
I have a For each that goes through an excel, if something is wrong, I use a Exception within the catch to stop this instance and continue with the next item in the loop…correct?
If an error happens, I want to process to halt at that point and continue to this next item in the loop.
But at the moment the whole process stops and flags the error instead of continuing
I’ve included a sample of the structure I have at the moment…what is wrong with it? Why wont it continue to the next loop item?
PS - I excluded the details from the attached sample so there will be validation errors - i’ve included it for structure purposes
Throwing an exception will make the program halt execution, going to the point where the exception is caught. If you want the loop to continue after an exception you should put your try/catch inside the loop and handle the exception during the operation of the loop.