Fork me on GitHub
TypeName CatchEmptyAnalyzer
Check Id CC0003
Category Design
Severity Warning

Cause

Catch statements with no Exception as an argument is not recommended. Consider adding an Exception class to the catch statement.

Example

try
{
    // do something
}
catch
{
    int x = 0;
}

Code fix

A code fix will be presented to you that will transform the code:

try
{
    // do something
}
catch (Exception ex)
{
    int x = 0;
}

Code fix

Related rules

  • CC0004 - Catch block should not be empty

See also

TBD