Throw from finally (ARCH404)
هذا المحتوى غير متوفر بلغتك بعد.
Key dotnet.exception.throw-from-finally · Severity error · Category exception
Throwing exceptions from finally blocks masks the original exception from the try or catch block, hiding the real cause of failure.
Incorrect
Section titled “Incorrect”try{ _repository.Save(order);}finally{ if (!_connection.IsClosed) throw new InvalidOperationException("Connection still open");}Correct
Section titled “Correct”try{ _repository.Save(order);}finally{ if (!_connection.IsClosed) _logger.LogWarning("Connection still open");}Log the condition instead of throwing in finally, or restructure the cleanup logic. If needed, suppress the rule per project/workspace via except/ignore.