org.sonar.l10n.java.rules.squid.S2737.html Maven / Gradle / Ivy
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