'Throwable' printed to 'System.out'
Reports calls to System.out.println()
with an exception as an argument.
Using print statements for logging exceptions hides the stack trace from you, which can complicate the investigation of the problem. It is recommended that you use logger instead.
Calls to System.out.print()
, System.err.println()
, and System.err.print()
with an exception argument are also reported. It is better to use a logger to log exceptions instead.
For example, instead of:
try {
foo();
} catch (Exception e) {
System.out.println(e);
}
use the following code:
try {
foo();
} catch (Exception e) {
logger.warn(e); // logger call may be different
}
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023