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

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

The newest version!

Multiple catch blocks of the appropriate type should be used instead of catching a general exception, and then testing on the type.

For example, following code:

try {
  /* ... */
} catch (Exception e) {
  if(e instanceof IOException) { /* ... */ }         // Non-Compliant
  if(e instanceof NullPointerException{ /* ... */ }  // Non-Compliant
}

should be refactored into:

try {
  /* ... */
} catch (IOException e) { /* ... */ }                // Compliant
} catch (NullPointerException e) { /* ... */ }       // Compliant




© 2015 - 2025 Weber Informatics LLC | Privacy Policy