Skip to content

Catch Clause Without Variable

Michael Damatov edited this page Jan 17, 2024 · 3 revisions

Catching the Exception without declaring an exception variable

try
{
    ...
}
catch (Exception) // '(Exception)' is redundant
{
    ...
}

is redundant and can be omitted:

try
{
    ...
}
catch
{
    ...
}

💡 A quick fix is available to remove the exception type declaration.

💡 The analyzer can be deactivated in the ReSharper Options dialog.