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 :
Microsoft Dynamics AX (Archived)

Exception Handling in X++

(0) ShareShare
ReportReport
Posted on by 2,626

Hello Guys,

i am trying tio handing exception in my code. i want the system generated error message when exception occured. i am using following code 

catch(Exception::Error)
{
sysException = CLRInterop::getLastException(); 
warning(sysException.get_InnerException());         -- Error occur in this line.
}

But it is giving error :- Error executing code: GL object not initialized.

*This post is locked for comments

I have the same question (0)
  • dolee Profile Picture
    11,279 on at

    Hi Vikas,

    You can refer to this post (community.dynamics.com/.../102485.aspx), I think it can help you.

    Regards,

    Dominic

  • Suggested answer
    Community Member Profile Picture
    on at

    Please verify following link which details all the information related to exception handling in X++

    msdn.microsoft.com/.../aa893385.aspx

    Please check for appropriate catch exception

  • Suggested answer
    Lauras U Profile Picture
    955 on at

    catch(Exception::Error) ?

    In this case you are catching x++ Dynamics ax errors. That's who CLRInterop::getLastException() is empty. If you were catching catch(Exception::CLRError), then you should refer to the links that are provided by our colleagues ;-)

  • Community Member Profile Picture
    on at

    Hope this will work ,

    msdn.microsoft.com/.../ee677495.aspx

  • Suggested answer
    Kashif Ali Profile Picture
    32 on at

    Hi Vikas,

    CLRInterop::getLastException() method calls only works with Exception::CLRError not other exception types. It returns null when called for other exceptions.

    Thats why your are getting this error "GL object not initialized" because sysException is null in your case.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans