Catch the exception of type Microsoft.Dynamics.Ax.Frameworks.Controls.ProductConfiguration.InvalidAttributePathException

I am stuck to catch the Exception for Microsoft.Dynamics.Ax.Frameworks.Controls.ProductConfiguration.InvalidAttributePathException, InvalidAttributePathException is not showing x++ class so we are not able to create object of this type. Since not able to catch this error it is showing error on the form and not able to log.

Error:-

at Microsoft.Dynamics.Ax.Frameworks.Controls.ProductConfiguration.Model.GetAttributeByXPath(String attributeXPath, Boolean acceptNoHit)\r\n at Microsoft.Dynamics.Ax.Frameworks.Controls.ProductConfiguration.Configurator.LoadAttributeValues(AttributeAssignments attributeAssignments)\r\n at Dynamics.AX.Application.PCRuntimeSynchronousConfigurator.loadAttributeValues() in xppSource://Source/Foundation\\AxClass_PCRuntimeSynchronousConfigurator.xpp:line 124\r\n at Dynamics.AX.Application.PCRuntimeSynchronousConfigurator.loadAttributeValues()\r\n at Dynamics.AX.Application.PCRuntimeSynchronousConfigurator.configure(String _model, String _valuesByXPath, Int32 _timeoutInMilliseconds, Boolean @_timeoutInMilliseconds_IsDefaultSet) in xppSource://Source/Foundation\AxClass_PCRuntimeSynchronousConfigurator.xpp:line 65\r\n at Dynamics.AX.Application.PCRuntimeSynchronousConfigurator.configure(String _model, String _valuesByXPath, Int32 _timeoutInMilliseconds, Boolean @_timeoutInMilliseconds_IsDefaultSet)\r\n at Dynamics.AX.Application.PCRuntimeSynchronousConfigurator.configure(String _model, String _valuesByXPath)\r\n at Dynamics.AX.Application.wfsUpdateProductConfiguration.updateProductLine(SalesLine salesLine) in xppSource://Source/WfsExtension\\AxClass_wfsUpdateProductConfiguration.xpp:line 216\r\n at Dynamics.AX.Application.wfsUpdateProductConfiguration.updateProductLine(SalesLine salesLine)\r\n at Dynamics.AX.Application.WfsNopOrderItem_Extension.Insert(nopOrderItem this) in xppSource://Source/WfsExtension\\AxClass_WfsNopOrderItem_Extension.xpp:line 14\r\n at WfsNopOrderItem_Extension::Insert(Object , Object[] , Boolean& )\r\n at Microsoft.Dynamics.Ax.Xpp.CommonChainOfCommandManager.MakeInstanceCall(Common instance, String methodName, Object[] parameters, Object& returnValue)\r\n at Microsoft.Dynamics.Ax.Xpp.Common.Insert()\r\n at Dynamics.AX.Application.NopSOQueueProcess.createSalesOrderOrShipment(Int32 _nopOrderID, JObject _jb, QueueClient _queueClient, BrokeredMessage _messager, Boolean @_queueClient_IsDefaultSet, Boolean @_messager_IsDefaultSet) in xppSource://Source/nopCommerce\AxClass_NopSOQueueProcess.xpp:line 796\r\n at Dynamics.AX.Application.NopSOQueueProcess.createSalesOrderOrShipment(Int32 _nopOrderID, JObject _jb, QueueClient _queueClient, BrokeredMessage _messager, Boolean @_queueClient_IsDefaultSet, Boolean @_messager_IsDefaultSet)\r\n at Dynamics.AX.Application.NopSOQueueProcess.createSalesOrderOrShipment(Int32 _nopOrderID, JObject _jb, QueueClient _queueClient, BrokeredMessage _messager)\r\n at Dynamics.AX.Application.NopSOQueueProcess.run() in xppSource://Source/nopCommerce\\AxClass_NopSOQueueProcess.xpp:line 933\r\n at Dynamics.AX.Application.NopSOQueueProcess.run()\r\n at Dynamics.AX.Application.SysOperationSandbox.startOperation(SysOperationIMarshalledRun operationInstance) in xppSource://Source/ApplicationPlatform\AxClass_SysOperationSandbox.xpp:line 100\r\n at Dynamics.AX.Application.SysOperationSandbox.startOperation(SysOperationIMarshalledRun operationInstance)\r\n at Dynamics.AX.Application.Runbase.runOperation() in xppSource://Source/ApplicationPlatform\\AxClass_Runbase.xpp:line 804\r\n at Dynamics.AX.Application.Runbase.runOperation()\r\n at Dynamics.AX.Application.NopSOQueueProcess.main(Args args) in xppSource://Source/nopCommerce\AxClass_NopSOQueueProcess.xpp:line 42\r\n at Dynamics.AX.Application.NopSOQueueProcess.main(Args args)\r\n at NopSOQueueProcess::main(Object[] , Boolean& )\r\n at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)

Could you please start from the beginning and tell us what you’re doing when you got the exception? It seems that you’re writing some custom code, right? If so, you seem to have a bug there, but we can’t comment on your code unless you share it with us.

Yes, Microsoft.Dynamics.Ax.Frameworks.Controls.ProductConfiguration.InvalidAttributePathException isn’t an X++ class, therefore it’s correct that you don’t see it in AOT. But you’re wrong in thinking that catching an exception requires creating an object. The object is created by code throwing an exception, not the one catching the exception.

You can either catch the specific exception, or all exceptions. For example, this catches all exceptions:

System.Exception ex;

try
{
    ...
}
catch (ex)
{
    ...
}

Hi Martin,

Thank you for the reply. I am already doing the same but not getting proper result so thought to create a object that type error. Below is the screenshot of the code. Actually I am trying to update the product configurator in sales line but there is any issue with solver name or value the error is thrown from "PCruntimsync…"class and I am trying log in custom table but the error is not coming in custom catch.

pastedimage1627381786465v2.png

I’m sorry, but what am I supposed to see in the screenshots? Does the first one shows that my suggested code actually works?

Your code is not working here. In the first screenshot the code is not moving inside of catch block.

As I see the screenshot, it seems to be showing that an exception has been caught. It even says which exception it is: System.AggregateException.

Hi Martin ,

After line number 223 it is not going inside Ln. 224 , it simple exit the method from all the caller classes.

Please make sure that you aren’t trying to catch the exception inside of a transaction. That’s not possible.

Then please create a simple runnable class demonstrating the problem and share the full class with us, so we can run your code and test it.