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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to get exceptions details in try catch X++

(0) ShareShare
ReportReport
Posted on by 66

Hi

I have some x++ code using to create a sales order with the sales line. Every now and then I get an error creating the dales line and it believe it probably missing data or an inaccurate use of an inventory dimension. I want to be able to surround the create line operation in a try catch and capture the error as string so I can store or report in another process. How do I extract the error message from Exception::Error 

Eg

try

{

     salesLine.createLine();

}

catch(Exception::Error)

{

   //What do I o here to extract the error

}

I have the same question (1)
  • Suggested answer
    nunomaia Profile Picture
    25 Moderator on at

    str error;
    
    try
        {
            // ...
        }
        catch (Exception::Error)
        {
            enumerator = SysInfologEnumerator::newData(infolog.cut());
    
            while (enumerator.moveNext())
            {
                strc = new SysInfologMessageStruct(enumerator.currentMessage());
                exception = enumerator.currentException();
    
                error = strfmt('%1 %2', error, strc.message());
            }
    
        }
        catch (Exception::CLRError)
        {
            netExcepn = CLRInterop::getLastException();
            error = netExcepn.ToString());
        }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans