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)

Error not being caught in 'Catch' of class method

(0) ShareShare
ReportReport
Posted on by 3,155

I have a Try/Catch in my code:

Try

{

...

}

catch (Exception::CLRError)

{

...

}

For some reason, my class won't catch the CLRError.  It is being caught further up the stack in another class. In this case FormLetterService.Run. (My code is called at the end of the Project invoice proposal posting)

Why would my 'local' 'Catch' statement not get the error instead of the FormLetterService class?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Joris dG Profile Picture
    17,775 on at

    Transaction scope? I have an oldie but goodie blog post on this: daxmusings.codecrib.com/.../exception-handling-in-dynamics-ax.html

  • b_radlyjames Profile Picture
    3,155 on at

    Ahhhhh yes... Good comment Joris... I completely forgot about this.  I've seen this behavior before and just forgot about transactions scope.

    This logic really should be outside of the transaction process... However, due to the risk involved I think the code done by our partner will have to remain where it is for the time being.

    In the meantime I think I will try and write some code to catch the problems before the system can throw an error.  Not full proof but should be good enough.

    Thanks for the reminder about Try/Catch inside transactions!

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