# Issue in Nested Loops with Try...Catch statement

**URL:** https://www.finalbuilder.com/forums/t/issue-in-nested-loops-with-try-catch-statement/3629
**Category:** Bugs
**Created:** [April 25, 2016, 2:16am UTC](https://www.finalbuilder.com/forums/t/issue-in-nested-loops-with-try-catch-statement/3629 "2016-04-25T02:16:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![blumentopf99](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/b/a698b9/32.png) [@blumentopf99](https://www.finalbuilder.com/forums/u/blumentopf99)
#### Post date: [April 25, 2016, 2:16am UTC](https://www.finalbuilder.com/forums/t/issue-in-nested-loops-with-try-catch-statement/3629/1 "2016-04-25T02:16:29Z")

</div>

Hi all,  
I have the following setup containing 2 loops and 2 Try/Catch blocks:  
  
Outer List Iterator Loop Start  
&nbsp; &nbsp; Try  
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; Try  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Inner Ini File Iterator Start  
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "###Do something"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Inner Ini File Iterator End  
&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; Catch  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Handle Exception  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Raise Exception for outer Try/Catch  
&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; Finally  
&nbsp; &nbsp; &nbsp; &nbsp; End  
&nbsp; &nbsp; Catch  
&nbsp; &nbsp; Finally  
&nbsp; &nbsp; End  
Outer List Iterator Loop End  
  
When the action "###Do something" fails I want the outer loop to continue with the next iteration, which uses a different Ini File for the inner Ini File Iterator. The inner Ini File Iterator loop shall process a specific Section in the Ini file one by one.   
  
However, after a previous error in "###Do something" the inner loop iterator does not start at the very first entry in the Ini file, instead, it seems to remember the iterator position (i.e. the line in the corresponding Ini file's section) where it was when the error in "###Do something" occurred. Since I'm leaving the inner loop using Try/Catch I expect the inner loop to start at the very first entry again.  
  
Isn't the loop exited when it's embedded in a Try/Catch block that throws an error?  
Can I somehow reset the internal iterator position manually?  
  
Thanks for your help!

---

<div class="post-metadata">

### Author: ![blumentopf99](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/b/a698b9/32.png) [@blumentopf99](https://www.finalbuilder.com/forums/u/blumentopf99)
#### Post date: [April 25, 2016, 3:16am UTC](https://www.finalbuilder.com/forums/t/issue-in-nested-loops-with-try-catch-statement/3629/2 "2016-04-25T03:16:08Z")

</div>

I created a small project to reproduce&nbsp; this&nbsp; behaviour. However, I can’t attach it (or any file!) to this thread, it’s always refused with the error “File type is not allowed”

---

<div class="post-metadata">

### Author: ![nevar](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/c4cdca/32.png) [@nevar](https://www.finalbuilder.com/forums/u/nevar)
#### Post date: [April 26, 2016, 2:53am UTC](https://www.finalbuilder.com/forums/t/issue-in-nested-loops-with-try-catch-statement/3629/3 "2016-04-26T02:53:58Z")

</div>

Hi,   
  
 Please feel free to email the sample project to [support@finalbuilder.com](mailto:support@finalbuilder.com).   
  
 In the meantime however I have found a bug which will be affecting what your attempting to achieve. The iterator in this case is not resetting back to the start after an exception is caused. I will fix this ASAP for you and update this post with a build when it is ready.

---

<div class="post-metadata">

### Author: ![nevar](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/c4cdca/32.png) [@nevar](https://www.finalbuilder.com/forums/u/nevar)
#### Post date: [April 26, 2016, 8:31am UTC](https://www.finalbuilder.com/forums/t/issue-in-nested-loops-with-try-catch-statement/3629/4 "2016-04-26T08:31:30Z")

</div>

Hi,   
  
 The updated build is located here:   
  
 [http://downloads.finalbuilder.com/downloads/finalbuilder/800/FB800\_1657.exe](http://downloads.finalbuilder.com/downloads/finalbuilder/800/FB800_1657.exe)   
  
 Note that you should only require one set of try…catch…finally…end. Handle the exception and allow the outer loop to tick over again. There is no need to re-raise the exception to the outer loop.

---

<div class="post-metadata">

### Author: ![blumentopf99](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/b/a698b9/32.png) [@blumentopf99](https://www.finalbuilder.com/forums/u/blumentopf99)
#### Post date: [April 26, 2016, 8:57am UTC](https://www.finalbuilder.com/forums/t/issue-in-nested-loops-with-try-catch-statement/3629/5 "2016-04-26T08:57:27Z")

</div>

Thanks for the quick response and the hot fix, it works fine in my test project!  
  
I have nested Try/Catches for design reasons, it’s easier to understand what’s going on and simplifies maintenance.
