Changes between Version 30 and Version 31 of MapGuideCodingStandards


Ignore:
Timestamp:
May 31, 2012, 4:24:52 AM (12 years ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideCodingStandards

    v30 v31  
    66
    77||'''Revision'''||'''Date'''||'''Author'''||'''Comment'''||
     8||1.6.1||31 May, 2012||Jackie Ng||More about exception handling||
    89||1.6||July 7, 2008||Bruce Dechant||Initial public revision||
    910
     
    744745}}}
    745746
     747== Exception Handling ==
     748
     749MapGuide employs a series of macros to simplify exception handling, propagation and stack trace recording. The macros are explained below:
     750
     751 * MG_TRY() - Denotes the start of a try/catch block. Also declares a local variable {{{mgException}}} of type {{{Ptr<MgException>}}}. If any exception is caught, it will be assigned to this variable.
     752 * MG_CATCH(methodName) - Denotes the end of a try/catch block. This macro defines catch blocks for common exception types ({{{MgException}}}, {{{std::exception}}} and {{{...}}}) and will append the current method name to the exception's call stack for any caught {{{MgExceptions}}}. You can do additional processing on the caught exception through the {{{mgException}}} local variable
     753 * MG_THROW() - Re-throws the caught exception. In order the preserve stack trace information on {{{MgException}}} objects, you have to re-throw caught exceptions, which this macro will do.
     754 * MG_CATCH_AND_THROW() - Is a combination of MG_CATCH() followed by MG_THROW(). Generally used when you don't need to do any custom processing on the caught {{{MgException}}} and generally just used to record the current method on the stack trace before throwing it back up.
     755
     756Each service API has service-specific variations of the above macros to do service-specific exception processing. It is generally advised to use these service-specific variations when dealing with code for that particular service (eg. Use MG_FEATURE_SERVICE_TRY(), MG_FEATURE_SERVICE_CATCH(), etc when working inside Feature Service code)
     757
     758Avoid the use of raw try/catch statements where possible, especially if you expect to catch exceptions of type {{{MgException}}}.
     759
    746760== Enumerations ==
    747761
     
    824838
    825839Use BOGUS in a comment to flag something that is bogus but works. Use FIXME to flag something that is bogus and broken. Use TODO when something needs to be completed but working. Code that is not implemented or not tested should raise an exception. For every instance add necessary comment to further explain the situation.
    826