web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Exception handling unable to catch " Error executing code: Overflow in internal run stack"

(0) ShareShare
ReportReport
Posted on by

Hi MS Pros! 

Have been bugged by this error stated in the subject line and thought that a simple try catch will do the trick but i am unable to catch the exception as it terminates the code rather than go to the usual Catch block.

I have tried all exception enums including the general exception catch (by not declaring any exception enums) but still unable to catch the error.

This is happening in an AX2009 environment and a fully customised batch job. I have traced the error is due to BOM Circularity and i do realise that we just troubleshoot the error and handled it but when i add a BOM Circularity check on the ItemIDs then the batch job will subsequently have performance issues. 

So the question is, how do i handle such exceptions (attached pic exception2)

exception2.jpg

also found a sample code online to force an exception but it is not catching as well

static void forceexception(Args _args)
{
       Date date1,date2,date3;
       int dateDiff;
       ;
     try
     {
       date1 = mkdate(01,01,2013);
       date2 = mkdate(10,01,2013);
       date3 = mkDate(15,01,2013);
       dateDiff = date3 - date2;
       info(strfmt("Date diff is: %1", dateDiff)); //dateDiff = 5
      date1 += dateDiff; //This works (You can only add positive integers, or subtract positive integers)
      info(strfmt("New date is: %1", date1));
     dateDiff = date2 - date3;
      info(strfmt("Date diff is: %1", dateDiff)); //dateDiff = -5
     date1 += dateDiff; //Runtime error: Error executing code: Wrong type of argument for conversion function.
     info(strfmt("New date is: %1", date1));
    }
    catch
    {
         error('test');
    }

}

this test script above does not reach the catch exception as per image below, regardless of exception enum (ie: Exception::error, exception::internal, etc).

exception1.JPG

Appreciate the help. if this is a limitation can someone please confirm so we can raise this with MS. 

Many thanks, 

Reynaldo

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Reynaldo,

    The first exception you listed seems like a code issue rather than runtime exception. However, the second one is known code restriction in X++ mentioned by Microsoft in KB 977664.

    support.microsoft.com/.../977664

    I don't think there is away to handle runtime exceptions as your code is violating the language constraints. These exceptions can only be fixed by changing the code in your logic.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans