public class Test {

    public static void main(String[] args) {
        Thread.currentThread().setUncaughtExceptionHandler(new MyExceptionHandler());

        for (int i = 10; i >= 0; i--) {
            System.out.println(10/i); // будет деление на ноль, а исключени попадет к нам))
        }

    }

    public static class MyExceptionHandler implements Thread.UncaughtExceptionHandler {
        @Override
        public void uncaughtException(Thread t, Throwable e) { // сюда
            System.out.println("Вуаля!");
            System.out.println(t.getName() + ": " + e.getClass().getSimpleName());
        }
    }

}