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

org.sonar.l10n.java.rules.squid.S2737.html Maven / Gradle / Ivy

There is a newer version: 8.6.0.37351
Show newest version

A catch clause that only rethrows the caught exception has the same effect as omitting the catch altogether and letting it bubble up automatically, but with more code and the additional detrement of leaving maintainers scratching their heads.

Such clauses should either be eliminated or populated with the appropriate logic.

Noncompliant Code Example

string s = "";
try {
  s = File.ReadAllText(fileName);
}
catch (Exception e) {  // Noncompliant
  throw e;
}

Compliant Code Example

string s = "";
try {
  s = File.ReadAllText(fileName);
}
catch (Exception e) {  // Compliant
  logger.LogError(e);
  throw e;
}

or

string s = File.ReadAllText(fileName);




© 2015 - 2025 Weber Informatics LLC | Privacy Policy