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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Why my error log contain old error message ?

(0) ShareShare
ReportReport
Posted on by

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,

I have the same question (0)
  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Can you try clearing the error by clicking clear in vs?

  • VoltesDev Profile Picture
    on at

    you mean like this :

    infolog.clear()

  • Suggested answer
    huijij Profile Picture
    19,811 on at

    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:

    learn.microsoft.com/.../xpp-exceptions

  • Suggested answer
    Mohit Rampal Profile Picture
    12,573 Moderator on at

    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;
    }

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    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.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 468 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans