COBCH1858 Preceding TRY block includes EXIT ITERATOR - CATCH not allowed

The program contains a TRY block in an iterator that includes an EXIT ITERATOR statement, and that same TRY block also has an associated CATCH. The associated CATCH in this scenario is not allowed; only FINALLY is permitted.

Resolution:

Correct the code; then recompile.

Example:

In the following example, the first TRY block is incorrect and the second is correct.

       class-id A.
       iterator-id MyIterator yielding ret as string.
           try
               set ret to "A"
               exit iterator
               set ret to "B"
               exit iterator
           catch                           *> Error
               display "Caught exception"
           end-try
           try
               set ret to "C"
               exit iterator
               set ret to "D"
               exit iterator
           finally                         *> ok
               display "In finally block"
           end-try
       end iterator.
       end class.