Wednesday, January 14, 2015

How Exception handling Try/Catch statements work in AX

A sample code for Try/Catch statements in AX under run method in a class.

public void run()
{
    #OCCRetryCount
   
    try
    {
       
    }
    catch (Exception::Deadlock)
    {
        retry;
    }
    catch (Exception::UpdateConflict)
    {
        if (appl.ttsLevel() == 0)
        {
            if (xSession::currentRetryCount() >= #RetryNum)
            {
                throw Exception::UpdateConflictNotRecovered;
            }
            else
            {
                retry;
            }
        }
        else
        {
            throw Exception::UpdateConflict;
        }
    }
}