title: Strange behavior with try-catch on Dynamics Ax 2012
body: <p>I'm trying without success to figure out what I'm doing wrong trying to handle one exception in my code, hopefully someone can help me.</p>
  
  <p>I'm reading an external database from within Ax to integrate some customers. So I loop through a series of records using a ResultSet object. at a given point I have some code that looks like this:</p>
  
  <pre><code>while (resultSet.next())
  {
      //some logic (...)
  
      ttsbegin;
  
      //This is a custom table that stores to where I want to integrate the given customer
      while select integrationCompany
              where integrationCompany.CRMCompany == customerInfo.parmCRMDataAreaId()
      {
          changeCompany(integrationCompany.ERPCompany)
          {
              try
              {
                  customerInfo.createCustomer();
  
                  //.. some more logic
  
  
              }
              catch
              {
                  // My catch Block, that should update the source database to set
                  // the processing status to "error"
  
  
                  ttsAbort;
              }
          }
      }
  
      ttsCommit;
  
  }
  </code></pre>
  
  <p>And inside the customerInfo.createCustomer() method I'm explicitly throwing some exceptions (throw Exception::Error) if some requirements aren't met.</p>
  
  <p>The problem is that the catch block isn't reached - the program stops without getting back to the main routine.</p>
  
  <p>Does it has something to do with the transaction opening/aborting/commiting or is something else?</p>