Hi guys,
In my Catch error, I usually write like this :
catch (Exception::Error) { Str1260 errorTxt = ""; int i; for (i=1; i<=Global::infologLine(); i ) { infolog.text(i); errorTxt = errorTxt ";/n" infolog.text(i); } . . . }
Then usually I will get that variable errorTxt and insert into my Log table (or just display on screen)
Question is why the errorTxt can contain old error message which is not from my current process ? how to clear the previous and only get the error message of current process ?
An example for this is, before I'm running my process, I'm open some other form and hit some standard error, then few minutes later I'm testing my code, ran and hit some error, but the error message will be started with the previous error before I'm running my code.
Thanks,
Hi, please debug the issue. It is supposed to give new error as it is a local variable. So, try debugging and check what buffer is present in errorTxt at line 3 (it should be empty) and check how it is changing at line 8.
Hi VoltesDev, We are using below code to capture infolog errors. Please check if it helps you.
protected str getMessagesFromInfoLog() { SysInfologEnumerator enumerator; SysInfologMessageStruct msgStruct; Exception exception; str error; enumerator = SysInfologEnumerator::newData(infolog.cut()); while (enumerator.moveNext()) { msgStruct = new SysInfologMessageStruct(enumerator.currentMessage()); exception = enumerator.currentException(); error = strfmt("%1 %2", error, msgStruct.message()); } infolog.clear(); return error; }
Hi VoltesDev,
The Global::infologLine() method is used to gets the number of error lines in the Infolog buffer. If you want to get the error message of current process, you can check the MS document about X++ exception handling:
you mean like this :
infolog.clear()
Can you try clearing the error by clicking clear in vs?
André Arnaud de Cal...
292,162
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156