Consultor Eletrônico



Kbase P136928: Throwing an exception in a FOR block does not LEAVE the block
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/5/2008
Status: Unverified

SYMPTOM(s):

Throwing an exception in a FOR block does not LEAVE the block

UNDO, THROW in a FOR EACH block goes to the NEXT iteration of that block

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.1C

CAUSE:

When executing code that does an UNDO, THROW inside a FOR EACH block performs the default processing for that block. FOR blocks have an implicit ON ERROR which performs an UNDO, NEXT when an error is raised.

FIX:

If you wish to exit a FOR block and raise the error to the the next level you should either design a CATCH block within the FOR block or design an explicit ON ERROR statement at the block level.

e.g.
FOR EACH ... :
....
CATCH err AS Progress.Lang.Error:
UNDO, THROW err.
END CATCH.
END.

or...

FOR EACH ... ON ERROR UNDO, THROW:
IF ... THEN
UNDO, THROW NEW Progress.Lang.AppError("message...").
END.