Avoid using printStackTrace
to log exceptions.
This rule reports code that tries to print the stacktrace of an exception. Instead of simply printing a stacktrace a better logging solution should be used.
fun foo() {
Thread.dumpStack()
}
fun bar() {
try {
// ...
} catch (e: IOException) {
e.printStackTrace()
}
}
Log exceptions properly by using a popular logging library.
val LOGGER = Logger.getLogger()
fun bar() {
try {
// ...
} catch (e: IOException) {
LOGGER.info(e)
}
}