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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Why try catch

(0) ShareShare
ReportReport
Posted on by

HI guys ,

I am little bit confused that ,

If I can do normal coding & with this functionality is working properly, then why we should use try catch in our methods.

your suggestions will be appreciated.

Thanks

*This post is locked for comments

I have the same question (0)
  • Dauvis Profile Picture
    170 on at
    RE: Why try catch

    The try/catch block are used to catch exceptions so that you can gracefully handle them.  The most common exceptions are the ones for dead lock and update conflict.  One way to use them is to have one that wraps a process or an atomic step in the process (the block will catch the errors in any methods that get called).

    I would like to add that the rules get a bit fuzzy when combining a try/catch with transactions (ttsBegin/ttsCommit).  Any exceptions will cause the whole transaction to be rolled back.  For more info: blogs.msdn.com/.../exception-handling-and-transactions.aspx

  • André Arnaud de Calavon Profile Picture
    297,767 Super User 2025 Season 2 on at
    RE: Why try catch

    Hi Mayur,

    With the try/catch you can capture errors and do specific actions with them. Usually the coding will just do what it needs to do.

    If you are using an external referenced dll, it might not be installed on the client, you can capture it and present a friendly message, the dll is missing in the installation.

    Or for long running tasks, you can capture e.g. a database lock and do a retry.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 2

#2
Rahul Shah Profile Picture

Rahul Shah 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans