Skip to main content

Notifications

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,

  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Why my error log contain old error message ?

    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.

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Why my error log contain old error message ?

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

  • Suggested answer
    huijij Profile Picture
    huijij 19,811 on at
    RE: Why my error log contain old error message ?

    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

  • VoltesDev Profile Picture
    VoltesDev on at
    RE: Why my error log contain old error message ?

    you mean like this :

    infolog.clear()

  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Why my error log contain old error message ?

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

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans