web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Get inner infologs in catch

(0) ShareShare
ReportReport
Posted on by 451
Hi,
 
I need to show infologs to users just before getting an error to let the users get the understanding of the real time setup errors.
Attaching the screenshot, currently I can only see the last error in red but I want to show above info message and warnings as well in the catch.
 
 
       try        {            code here...        }               catch(errorEx)        {            response.parmErrorMessage(errorEx.Message);        }        catch(Exception::CLRError)        {            System.Exception interopException = CLRInterop::getLastException();            response.parmErrorMessage(interopException.ToString());        }        return response;
Thanks!
I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    You seem to be saying that an info and warning message were added to infolog before an exception was thrown. You want to remove these two messages and add them again as errors. Is it the case? Are you sure it's a good idea? Even if you prefer converting infos and warnings to errors, you must take into account how F&O works. Your change would impact just a single place and the rest of the application will keep behaving as before. Introducing this inconsistency may be worse than not doing anything.
  • Dev Profile Picture
    451 on at
    Hi Martin,
     
    I want catch these two messages as well and show them to users apart from the error message which is a generic message.
    I have added a catch section where in I want to show these three messages as a response two a request where this code is called.
     
    thanks!
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    The functional requirement can be implemented, but your technical design ("I want catch these two messages") is impossible. You can catch exceptions, not infolog messages.

    As I said, the way how you could achieve your goal is removing the existing messages from infolog and them again with a different type. You'll run your logic when you catch an exception.
     
    But I wouldn't do it. You seem to suggest that if you change these two messages, users won't need to know how to interpret infolog message, but it would be true only if they never touched any other part of F&O. All other logic will still work the same - it won't convert existing infolog messages to errors.
     
    By the way, I think that the type of the first message is wrong. It should be a warning, at least. Maybe this is the bug you need to address.
  • Dev Profile Picture
    451 on at
    Thank you Martin. I understood your point. I do not want to convert the info and warning into error.
    I just want to understand that can we not catch the exception type as warning or info if they occur before error.
  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    Again, you can't catch infolog messages. What you can catch are exceptions, which is a different thing.
     
    For example, try this code:
    try
    {
        info("Info");
        warning("Warning");
        error("Error");
        
        info("Try block completed successfully");
    }
    catch
    {
        // This will never execute, because no exception was thrown.
        info("Exception caught");
    }
    It adds messages to infolog, but that's it. There is no exception thrown and therefore nothing to catch.
     
    Now consider another examples. It throws and exception without any infolog message, proving again that they're two independent concepts:
    try
    {
        throw Exception::Error;
    }
    catch
    {
        info("Exception caught");
    }
    Your confusing comes from the fact that adding an error message to infolog and throwing an exception is often done at a single line:
    // Usual way
    throw error("x");
    
    // The same thing, just with each statement on a separate line
    error("x");
    throw Exception::Error;
    
    When you use code like info(), warning() or checkFailed(), you aren't throwing an exception and therefore code can continue (such as checking other conditions and adding more messages to infolog).

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans