Exception Do and Don'ts

From Microsoft MSDN.


1.Do not return error codes. Exceptions are the primary means of reporting errors in frameworks.

2.Do report execution failures by throwing exceptions. Consider terminating the process by calling System.Environment.FailFast. Do not use exceptions for normal flow of control, if possible. Except for system failures and operations with potential race conditions

3. onsider the performance implications of throwing exceptions.

4.Consider using exception builder methods. It is common to throw the same exception from different places. To avoid code bloat, use helper methods that create exceptions and initialize their properties.

5.Do not throw exceptions from exception filter blocks. If you're C# programmer ; you can ignore this.

6.Avoid explicitly throwing exceptions from finally blocks. Implicitly thrown exceptions resulting from calling methods that throw are acceptable.

Comments

Popular posts from this blog

ionic2 cordova build android - Unable resolve gradle 2.2.3

OpenCover code coverage for .Net Core

Using Custom DLL with IronPython / Scripts