Skip to content

Catch Clause Without Variable

Michael Damatov edited this page Sep 10, 2025 · 4 revisions

Catching the Exception without declaring an exception variable

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

is redundant and can be omitted:

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

Tip

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

Note

The analyzer can be configured or deactivated in the ReSharper Options or Rider Settings dialog.

Clone this wiki locally