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 show original system error in Try..Catch

(0) ShareShare
ReportReport
Posted on by 709

Hello everyone,

In usual Try.. Catch, as per my understanding, we can specified the error like for example 

catch (Exception::Error)
{
      error("Calculation terminated");
}

And if I correct, when we call Throw Error(""); this will be redirect to that above Catch, and the same error message will be shown.

Is there a function to show the original error message or whatever the system provide us that "notify" us there is an error, instead our own error message ?

Please advice.

Thanks

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

    You can capture info error messages, like this. This is your goal? 

    str msg;
    int i;
    // ...
    for (i = i   1; i <= infolog.line(); i  )
    {
        msg  = infolog.text(i);
    }

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi ShaqAX ,

    I guess your question was related to the blog written by  goshoom . Refer to the below blog post.

    https://dev.goshoom.net/2018/10/throwing-managed-exceptions/

    Is this you are asking?

    Thanks,

    Girish S.

  • ShaqAX Profile Picture
    709 on at

    If not mistaken, what Martin described in his blog is for us to maintain also the "throw", so not only the "catch" ?

    Actually my intention is to just info-ing whatever the system "denies" our entry, so even when we throw error or error by the system it self, we can show the error from the system whatever it is.

    Is there possibility even when we throw the error out selves, we can show the original message from system ? For example my experiences is I put Throw error("Failed"), with the infolog.text() will also display the message that I throw, but in fact there is something else with the process that I build that having issue, for example the class missing method.

    Thanks

  • Suggested answer
    Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    What you need is covered by another blog post: Catching exceptions in AX 7.

    The usual approach was getting the message from infolog, but in F&O, you can also catch Microsoft.Dynamics.Ax.Xpp.ErrorException and get the message from there.

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 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans