Error Handling Design Tips

in
Average rating
(0 votes)

Here are some Design Tips on Error Handling or Exception Handling:

1. ArgumentException should be used if invalid parameters are passed.
2. Catch block should log exceptions to event log
3. Directory.GetFiles() method requires try/catch block
4. Do not create methods that throw System.SystemException
5. Do not create methods that throw System.Runtime.InteropServices.ExternalException
6. Do not create methods that throw System.NullReferenceException
7. Do not create methods that throw System.Exception
8. Do not create methods that throw IndexOutOfRangeException
9. Use trace in function entrance and exit
10 Use trace in function entrance and exit
11 Test for Null argument before referencing
12 StreamReader reference should have try/catch block protecting it
13 Should not inherit indirectly from System.SystemException
14 Should not inherit directly from System.Exception
15 Should have central try/catch block in main() function
16 Re-throw should not throw with argument.
17 Localize strings for any exception messages
18 Exception classes Must Be Marked Serializable
19 Exception class names must end in the word "Exception"