How to throw user define exception in AX

Today I will demonstrate you that How to throw user define exception in AX.

EmpData e;
 try
{
                    select  e where e.Name=="John";
                    if(!e.Name)
                                         throw error("Invalid Name");
                    else
                                         info(e.Name);
 }
catch(Exception::error)
{
                    error("Exception occured");

}

Comments