Notifications
Announcements
No record found.
Hey Team,
I want the system generated error message when an exception has occurred. Please can you let me know how can I get this using x++ code.
I want to store the errors in a table.
You can hook in Classes\Info\add to get this info.
Hi,
do you mean you want to catch the exception in your own code and throw as an error? please share more details on your requirement. X++ exception/error handling is pretty robust now.
hey Mingzhou Deng,
Yes, actually I want to catch the exception and show it to the user on the UI as my code runs as a batch job and therefore if any error occurs I want to catch the exception and show it to the user on the UI
Hey Nikolaos Mäenpää,
Can you please elaborate a little more on this, how can I do this?
Aha, so this is duplicate of your other thread, Show Batch Job Error on the UI, the difference is that you didn't explain your actual problem here. It seems we should abandon this thread and continue the original one.
Hey Martin Dráb ,
Yes, we can continue there. I initially planned to get the batch job logs but it seems to be difficult so later I thought of using the exception in catch block hence I created a new thread.
If you have a different intent in this thread, explain it. We can't read your mind - we depends on what you wite down, which wasn't much.
We can't help you if you didn't do your part and explain your problem in sufficient detail.
Okay, I will explain in detail what I need. I have a batch job which runs to create associates(or users simply), many a times the batch job fails due to some reason. I have a logTable which stores details of the batch job. If the associate is created successfully it stores details as "Associate created successfully" but if there is an error in the batch job I want to show that as well on UI and store it in the logTable.So I have a try catch block in my batch job so if the batch job fails I want to catch the system generated Exception from the batch job and store it in my log table.
My catch block:
AssociateTable associate; catch(Exception::Error) { if (associate.RecId) { ttsbegin; Error(strFmt("@HRM:AssociateCreationErrorStatus")); associate.AssociateStatus = AssociateStatus::Failed; associate.update(); ttscommit; } }
My log table
Example of the exception I want to show:
//just an example I copied from the docs:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: StartIndex cannot be less than zero. Parameter name: startIndex at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) at System.String.Substring(Int32 startIndex) at ClrBridgeImpl.InvokeClrInstanceMethod(ClrBridgeImpl* , ObjectWrapper* objectWrapper, Char* pszMethodName, Int32 argsLength, ObjectWrapper** arguments, Boolean* argsAreByRef, Boolean* isException) **********/ }
That's definitely the same topic as in your other thread. As already discussed there, you have this information in existing batch logs. I would avoid duplicating it, but if you want, look at how it's done in the standard application.
If you have more question on this topic, ask them in Show Batch Job Error on the UI.
Hey Martin Dráb,
I found a blog which I feel is similar to my issue I have added that blog in my previous thread could you pls help with that blog. Will that blog resolve my issue?
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
André Arnaud de Cal... 456 Super User 2025 Season 2
Martin Dráb 429 Most Valuable Professional
BillurSamdancioglu 239 Most Valuable Professional