Help
package com.codegym.task.task25.task2512;
import java.util.Collections;
import java.util.LinkedList;
/*
Charting our own course
*/
public class Solution implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(Thread t, Throwable e) {
t.interrupt();
Throwable ie = e;
String s = "";
LinkedList<Throwable> list = new LinkedList<>();
while (true) {
list.push(ie);
ie = ie.getCause();
if (ie.getCause() == null) {
list.push(ie);
break;
}
}
for (Throwable th : list) {
System.out.println(th);
}
}
public static void main(String[] args) throws Exception {
Solution s = new Solution();
Thread.setDefaultUncaughtExceptionHandler(s);
throw new Exception("ABC", new RuntimeException("DEF", new IllegalAccessException("GHI")));
}
}