Microsoft Dynamics AX 2012 R3 Development-2 Locus IT Services

Microsoft Dynamics AX 2012 R3 Development-2

Locus IT ServicesMicrosoft Dynamics AX 2012 R3 Development-2

Lesson 2- Try and Catch Statements

Try and Catch Statements

Try statements signify the start of a block of code that you want to control with the X++ exception handling system. Any exceptions that are thrown in that block of code can be caught and handled in the associated Catch statements.

Catch statements come after the Try statement and define what code is executed when each exception is thrown. You do not have to define for every possible exception. However, each Try statement must have at least one . It is also possible to defines that is executed for any exception type. Try statements can be made within the scope of other Try statements. If a Catch statement is not defined for the exception being thrown by an inner Try statement, the code will step out to the next outer Try statement to attempt to find a matching for the exception. This will continue until a Catch statement is found, or there are no more outer Try statements.

Retry statements tell the system to go back to the Try statement and attempt to execute the code again. Any data that is loaded before the Try statement will remain as it is, but any data retrieved or modified after the Try statement will be refreshed.

Locus IT Project Management Office
What’s it?