KT.PRINT_STACK_TRACE
Print the stacktrace of an exception
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.
Noncompliant Code
Copy
fun foo() {
Thread.dumpStack()
}
fun bar() {
try {
// ...
} catch (e: IOException) {
e.printStackTrace()
}
}
Compliant Code
Copy
val LOGGER = Logger.getLogger()
fun bar() {
try {
// ...
} catch (e: IOException) {
LOGGER.info(e)
}
}