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)

'server' method throwing error needs to be 'caught' for more meaningful message.

(0) ShareShare
ReportReport
Posted on by 3,157

Here is what I'm trying to do.

I am calling code which eventually leads us to Classes\DimensionDefaultingEngine\constructForMainAccountId method. This method will throw the following error correctly:

if (!_mainAccountId || !_accountStructureId)
{
throw error(Error::wrongUseOfFunction(funcName()));
}

The account structure for the main account is not setup correctly.  This is perfectly fine. The error should be thrown.

What I want to do is 'catch' this thrown error so that I can give the user a more meaningful message to have them fix the problem.

try { ...}

catch (Exception::error){

error("Meaningful message");

}

This try / catch doesn't seem to want to do anything.

*This post is locked for comments

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

    try-catch in AX has specific behaviors based on transaction scope. The code where you placed the try catch is likely being called from within a transaction scope, which means you essentially can't catch it.

    Check this out: daxmusings.codecrib.com/.../exception-handling-in-dynamics-ax.html

  • b_radlyjames Profile Picture
    3,157 on at

    Thanks Joris!  This was exactly it.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#1
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#1
Pratik Bhosle Profile Picture

Pratik Bhosle 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans