Do not raise reserved exception types

TypeName

DoNotRaiseReservedExceptionTypes

CheckId

CA2201

Category

Microsoft.Usage

Breaking Change

Breaking

Cause

A method raises an exception type that is too general or that is reserved by the runtime.

Rule Description

The following exception types are too general to provide sufficient information to the user:

The following exception types are reserved and should be thrown only by the common language runtime:

How to Fix Violations

To fix a violation of this rule, change the type of the thrown exception to a specific type that is not one of the reserved types.

When to Exclude Warnings

Do not exclude a warning from this rule.

Do not catch general exception types

Do not raise exceptions in filter blocks