Ir al contenido

Empty catch block (ARCH401)

Esta página aún no está disponible en tu idioma.

Key dotnet.exception.empty-catch-block · Severity error · Category exception

Empty catch blocks silently swallow exceptions and hide bugs, making debugging harder. The caught exception should at least be logged or rethrown.

try
{
_repository.Save(order);
}
catch
{
}
try
{
_repository.Save(order);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to save order");
throw;
}

Log, handle, or rethrow the exception; do not leave the catch block empty. If needed, suppress the rule per project/workspace via except/ignore.