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

System.Exception catch

(0) ShareShare
ReportReport
Posted on by 465

Hi,

I thought system.Exception catches everything

So i had the following

Catch(Exception:Error)

{

  Here i return what is saved in sysInfoLog

Catch(ex) //this is system.Eception

{

   Info(ex.Message)

}

Catch{ i also return what is inside sysInfoLog}

Now what happened is, during inserting into logisiticsPostalAddressEntity.. An error occured that says countryRegionId should be filled

If there was no catch for the system exception, then the general catch will return this missage for me.(not sure why this wasn't catched by the error catch??? ) 

However when i added the system.Exception catch, the debug entered this catch. However it returned  nothing.

Does that mean that inside the ex catch, i should check if ex.Message==null then check the sysInfolog? But why it returned nothing? 

I have the same question (0)
  • huijij Profile Picture
    19,811 on at
    RE: System.Exception catch

    Hi sir,

    A direct throw of Exception::Error does not display a message in the Infolog. And the Global::error method is recommended.

    https://docs.microsoft.com/en-us/dynamicsax-2012/developer/exception-handling-with-try-and-catch-keywords#sample-2-error-method-to-write-exception-to-infolog

    regards

  • D365FO user Profile Picture
    465 on at
    RE: System.Exception catch

    Hi Judy,

    Thanks for that. But i'm not throwing errors, I'm catching them

    And my question was about system.Exception..it seems i should not print in the catch ex.Message i should check if it's null as well to display sysInfolog message because it seems sometimes  ex.message is empty even though the debug entered the catch 

  • Martin Dráb Profile Picture
    236,471 Most Valuable Professional on at
    RE: System.Exception catch

    Please use the debugger to check the type and properties of the exception. Then share the information with us.

    By the way, please always use Insert > Insert Code to paste source code here. It makes code easier to read, e.g. it prevents the double line spacing. This is your code posted in the right way (I also fixed letter case at a few places):

    catch (Exception:Error)
    {
    	...
    } 
    catch (ex) // this is System.Exception
    {
       info(ex.Message)
    }

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,964

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 564 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans