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
Thanks Joris! This was exactly it.
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,228 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156