C#

C#

Made by DeepSource

Exception caught is generic CS-R1008

Anti-pattern
Major

The exception caught is generic and defeats the purpose of exception handling. Each type of exception provides an insight into what exactly went wrong and provides scenario-specific ways for graceful recovery. While it is easy to recover from some exceptions, a small subset of them make the recovery very difficult, usually because the conditions are not suitable for the program to continue executing. It is therefore suggested that you switch to a better approach of exception handling and recovery.

Bad Practice

try
{
    var num = int.Parse(input);
}
catch (Exception)
{
    // ...
}

Recommended

try
{
    var num = int.Parse(input);
}
catch (ArgumentException)
{
    // ...
}

References: