Empty catch block (ARCH401)
هذا المحتوى غير متوفر بلغتك بعد.
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.
Incorrect
Section titled “Incorrect”try{ _repository.Save(order);}catch{}Correct
Section titled “Correct”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.