ReSharper 2024.1 Help

Code Inspection: Empty general catch clause

Category

Potential Code Quality Issues

ID

EmptyGeneralCatchClause

EditorConfig

resharper_empty_general_catch_clause_highlighting

Default severity

Warning

Language

C#

Requires SWA

No

Consider the following code snippet:

string text = ""; try { text = File.ReadAllText("test.txt"); } catch { }

In this snippet, the catch clause catches absolutely all errors. Since a non-response to an exception is a fairly rare (and potentially dangerous) thing, ReSharper warns about this and offers to catch an Exception. There are, however, usages of a catch-all statement that are justified.

Last modified: 15 April 2024