Exceptional is an extension for ReSharper which analyzes thrown and documented exceptions and suggests improvements.

Motivation

When working with a code base - whether it is a small one or a big one - developers constantly encounter issues caused by wrong exception handling. There may be an excellent exception handling policy, but it is the developer who must execute this policy on its own code. Even with no policy defined, there are good practices on how to properly handle exceptions. This extension allows you to seamlessly apply these good practices with a couple of key strokes.

Generally, the public API should be documented and thrown exceptions should be part of this documentation. But even if documenting thrown exceptions is pretty easy, the maintenance of the code that is using a particular method or property is not. This is where this extension comes into play: The extension analyzes call sites and provides hints on exceptions thrown from that invocations. If an exception is either not caught or not documented then you will be proposed to fix this problem. The extension also checks other good practices, for example that an inner exception is provided when rethrowing a new exception.

Installation

Requires ReSharper v8.2+
  • Open the ReSharper menu in Visual Studio and select Extension Manager...
  • Search for Exceptional and install the extension
Open the menu ReSharper / Options... / Exceptional to configure the extension.

Features

Thrown exception not documented or catched

Warning: Exceptions thrown outside the scope of method\property that are not documented in methods xml documentation (thrown with use of throw keyword).

01_ExceptionNotDocumentedWarning.png

Fix: Document or catch thrown exception.

02_ExceptionNotDocumentedFix.png

Warning: Exception thrown outside the scope of method\property that are not documented in methods xml documentation (thrown from another invocation).

03_ExcpetionNotDocumentedWarning.png

Fix: Document or catch thrown exception.

04_ExcpetionNotDocumentedFix.png

Documented exception is not thrown

Warning: Exceptions documented in xml documentation that are not thrown from method/property.

05_WrongExceptionDocumentationWarning.png

Fix: Remove documentation of not thrown exception.

06_WrongExceptionDocumentationFix.png

Catch-all clauses and not passing inner exception

Warning: General catch-all clauses should be avoided.

07_CatchAllExceptionsWarning.png

Warning: Throwing new exception from catch clause should include message and inner exception.

08_MissingInnerExceptionWarning.png


More features to come!

Last edited Oct 17 at 8:18 PM by rsuter, version 47