A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2219 below:

CA2219: Do not raise exceptions in exception clauses (code analysis) - .NET

Property Value Rule ID CA2219 Title Do not raise exceptions in exception clauses Category Usage Fix is breaking or non-breaking Non-breaking, Breaking Enabled by default in .NET 9 As suggestion Cause

An exception is thrown from a finally, filter, or fault clause.

Rule description

When an exception is raised in an exception clause, it greatly increases the difficulty of debugging.

When an exception is raised in a finally or fault clause, the new exception hides the active exception, if present. This makes the original error hard to detect and debug.

When an exception is raised in a filter clause, the runtime silently catches the exception, and causes the filter to evaluate to false. There is no way to tell the difference between the filter evaluating to false and an exception being throw from a filter. This makes it hard to detect and debug errors in the filter's logic.

How to fix violations

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

When to suppress warnings

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.

CA1065: Do not raise exceptions in unexpected locations

See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4