More actions
New page: == Introduction == This guideline contains CatGlobe-specific coding rules. |
No edit summary |
||
Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
This guideline contains CatGlobe-specific coding rules. | This guideline contains CatGlobe-specific coding rules. | ||
== Exception == | |||
=== Exception handling === | |||
*Only catch exception if you can do some thing with it. | |||
*All re-thrown exception must include the original exception in its inner exception. | |||
*DO: always catch specific exception type. You are allowed to catch generic exception and re-throw a specific exception; for example in CGScript all exceptions are caught and a RuntimeException is re-thrown afterward. | |||
*DO NOT: empty and undocumented catches; using unspecific catches, unless they are documented well in the design document and are approved by the PMs. | |||
=== Create a new custom of exception === | |||
*Naming rule: the new exception must be suffixed with “Exception”. | |||
*All custom exceptions must inherit from another exception class. | |||
*The exception should be serializable in order to use in CatTask service. Refer to [[Serializable exceptions]] for more details. Notice: when the new CatTask service is done, this may be obsolete. | |||
*Namespace rule: | |||
- If the being created exception is used in multiple places, it must be placed in the CatGlobe.Framework.Exceptions namespace. | |||
- Otherwise, if it is used for a specific class only, it can be placed in the namespace where it is used. |
Revision as of 02:19, 17 December 2008
Introduction
This guideline contains CatGlobe-specific coding rules.
Exception
Exception handling
- Only catch exception if you can do some thing with it.
- All re-thrown exception must include the original exception in its inner exception.
- DO: always catch specific exception type. You are allowed to catch generic exception and re-throw a specific exception; for example in CGScript all exceptions are caught and a RuntimeException is re-thrown afterward.
- DO NOT: empty and undocumented catches; using unspecific catches, unless they are documented well in the design document and are approved by the PMs.
Create a new custom of exception
- Naming rule: the new exception must be suffixed with “Exception”.
- All custom exceptions must inherit from another exception class.
- The exception should be serializable in order to use in CatTask service. Refer to Serializable exceptions for more details. Notice: when the new CatTask service is done, this may be obsolete.
- Namespace rule:
- If the being created exception is used in multiple places, it must be placed in the CatGlobe.Framework.Exceptions namespace.
- Otherwise, if it is used for a specific class only, it can be placed in the namespace where it is used.