Consultor Eletrônico



Kbase P171035: 4GL/ABL: Structured Error Handling related questions 
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   09/09/2010
Status: Unverified

GOAL:

4GL/ABL: Structured Error Handling related questions

GOAL:

What is the difference between the following two CATCH constructs?

CATCH eAppError AS Progress.Lang.AppError:
RETURN ERROR eAppError.
END CATCH.

and
CATCH eAppError AS Progress.Lang.AppError:
UNDO, THROW eAppError.
END CATCH.

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.1C

FIX:

The difference between the above two CATCH constructs is the RETURN ERROR eAppError causes control to return immediately to the calling procedure while the UNDO, THROW eAppError raises the ERROR in the block enclosing the CATCH associated block and the error is thrown to the caller only if the catch block is at the routine level. In other words, in the construct:

CATCH eAppError AS Progress.Lang.AppError:
RETURN ERROR eAppError.
END CATCH.

The RETURN ERROR eAppError immediately returns to the caller before throwing the error object ignoring any CATCH blocks or ON ERROR directives in effect at the time of the RETURN.
while, in the construct:
CATCH eAppError AS Progress.Lang.AppError:
UNDO, THROW eAppError.
END CATCH.


The UNDO, THROW eAppError causes the AVM to raise ERROR in the block that encloses the associated block of the CATCH block; not the associated block itself. If the catch block is at the routine level, then the error gets thrown to the caller of the routine.