Skip to content

Commit ad90c00

Browse files
authored
Add code example for CA2219 rule (#49062) (#49063)
1 parent 91439ea commit ad90c00

File tree

1 file changed

+16
-0
lines changed
  • docs/fundamentals/code-analysis/quality-rules

1 file changed

+16
-0
lines changed

docs/fundamentals/code-analysis/quality-rules/ca2219.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ helpviewer_keywords:
1010
- CA2219
1111
author: gewarren
1212
ms.author: gewarren
13+
dev_langs:
14+
- CSharp
1315
---
1416
# CA2219: Do not raise exceptions in exception clauses
1517

@@ -37,6 +39,20 @@ When an exception is raised in a filter clause, the runtime silently catches the
3739

3840
To fix this violation of this rule, do not explicitly raise an exception from a `finally`, filter, or fault clause.
3941

42+
## Example
43+
44+
```csharp
45+
try
46+
{
47+
// ...
48+
}
49+
finally
50+
{
51+
// This code violates the rule.
52+
throw new Exception();
53+
}
54+
```
55+
4056
## When to suppress warnings
4157

4258
Do not suppress a warning for this rule. There are no scenarios under which an exception raised in an exception clause provides a benefit to the executing code.

0 commit comments

Comments
 (0)