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

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

The newest version!

Throwable.printStackTrace(...) prints a throwable and its stack trace to some stream.

Loggers should be used instead to print throwables, as they have many advantages:

  • Users are able to easily retrieve the logs.
  • The format of log messages is uniform and allow users to browse the logs easily.

The following code:

try {
  /* ... */
} catch(Exception e) {
  e.printStackTrace();        // Non-Compliant
}

should be refactored into:

try {
  /* ... */
} catch(Exception e) {
  LOGGER.log("context", e);   // Compliant
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy