All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.csharp.S1163.html Maven / Gradle / Ivy

There is a newer version: 10.2.0.105762
Show newest version

Why is this an issue?

If an exception is already being thrown within the try block or caught in a catch block, throwing another exception in the finally block will override the original exception. This means that the original exception’s message and stack trace will be lost, potentially making it challenging to diagnose and troubleshoot the root cause of the problem.

try
{
  // Some work which end up throwing an exception
  throw new ArgumentException();
}
finally
{
  // Cleanup
  throw new InvalidOperationException(); // Noncompliant: will mask the ArgumentException
}
try
{
  // Some work which end up throwing an exception
  throw new ArgumentException();
}
finally
{
  // Cleanup without throwing
}

Resources

Documentation





© 2015 - 2024 Weber Informatics LLC | Privacy Policy