Pattern: Printing stacktrace of an exception
Issue: -
Instead of simply printing a stacktrace a better logging solution should be used.
Example of incorrect code:
fun foo() {
Thread.dumpStack()
}
fun bar() {
try {
// ...
} catch (e: IOException) {
e.printStackTrace()
}
}
Example of correct code:
val LOGGER = Logger.getLogger()
fun bar() {
try {
// ...
} catch (e: IOException) {
LOGGER.info(e)
}
}