Quantcast
Channel: Java mon amour
Viewing all articles
Browse latest Browse all 1124

JMC: how to capture details of caught and unlogged exceptions

$
0
0
It happens occasionally that inexperienced programmers catch an exception and ignore it, or they catch it and throw another exception without reporting the full details of the root cause.

This situation turns naturally in an operational nightmare.

But Java Mission Control can really help you out. Let´s run this code:

public class ThrowsException {
public static void main(String[] args) {
while (true) {
try {
Thread.sleep(1000);
throw new Exception("ciao bella gioia");
}
catch (Throwable t) {
}
}
}
}


I run the JMC flight recorder, then go to the Code/Exceptions tab and this is what I get:


Viewing all articles
Browse latest Browse all 1124

Trending Articles