Recursion did indeed work for me too. Took me about four hours to figure out wtf code gym even wanted of course and then research all the stuff they havn't told/taught us.
Anyone want guidance on this task, pm me.
I passed the assignment but have no clue how the iteration worked!!!
the iteration is adding the throwable String representation to the list e.toString(); then assigning e to e = e,getCause();
I can't even for the life of me get more than one throwable created in main to debug what is going on. Please ping me or post some article here to help me undertsand.
Thanks
For "Charting our own course":
For anyone who, like Fadi, was having problems getting more than one exception thrown so that they could debug the issue:
I copied this code from Bill Wu, who posted asking for help on this problem
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")));
}
By using Thread.setDefaultUncaughtExceptionHandler(s), he sets the main thread (and all threads that don't have one set) to also use the exception handler we're creating.
Then you can set public static void main(String[] args) to allow exceptions with the "throws Exception" tag.
Once that's done you can just go ahead and throw the exception that CodeGym gives as an example.
GO TO FULL VERSION