Sunday, November 8, 2015

JMC: how to capture details of caught and unlogged exceptions

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 (remember the -XX:+UnlockCommercialFeatures -XX:+FlightRecorder ) :
public class ThrowsException {
 public static void main(String[] args) {
  while (true) {
   try {
    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:

No comments: