fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class L1Exception extends Exception { public L1Exception(Throwable cause) { super(cause); } }
  6. class L2Exception extends Exception { public L2Exception(Throwable cause) { super(cause); } }
  7. class L3Exception extends Exception { public L3Exception(Throwable cause) { super(cause); } }
  8. class L4Exception extends Exception { public L4Exception(Throwable cause) { super(cause); } }
  9. class L5Exception extends Exception { public L5Exception(Throwable cause) { super(cause); } }
  10.  
  11. class CheckedExceptions {
  12.  
  13. static void doSomethingL5(int x) throws L5Exception {
  14. try {
  15. doSomethingL4(x * 3 + 0);
  16. doSomethingL4(x * 3 + 1);
  17. doSomethingL4(x * 3 + 2);
  18. } catch (L4Exception e) {
  19. throw new L5Exception(e);
  20. }
  21. }
  22.  
  23. static void doSomethingL4(int x) throws L4Exception {
  24. try {
  25. doSomethingL3(x * 3 + 0);
  26. doSomethingL3(x * 3 + 1);
  27. doSomethingL3(x * 3 + 2);
  28. } catch (L3Exception e) {
  29. throw new L4Exception(e);
  30. }
  31. }
  32.  
  33. static void doSomethingL3(int x) throws L3Exception {
  34. try {
  35. doSomethingL2(x * 3 + 0);
  36. doSomethingL2(x * 3 + 1);
  37. doSomethingL2(x * 3 + 2);
  38. } catch (L2Exception e) {
  39. throw new L3Exception(e);
  40. }
  41. }
  42.  
  43. static void doSomethingL2(int x) throws L2Exception {
  44. try {
  45. doSomethingL1(x * 3 + 0);
  46. doSomethingL1(x * 3 + 1);
  47. doSomethingL1(x * 3 + 2);
  48. } catch (L1Exception e) {
  49. throw new L2Exception(e);
  50. }
  51. }
  52.  
  53. static void doSomethingL1(int x) throws L1Exception {
  54. if (x == 42) {
  55. throw new L1Exception(null);
  56. }
  57. }
  58.  
  59. public static void main (String[] args) throws Exception {
  60. doSomethingL5(0);
  61. }
  62. }
Runtime error #stdin #stdout #stderr 0.11s 320512KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" L5Exception: L4Exception: L3Exception: L2Exception: L1Exception
	at CheckedExceptions.doSomethingL5(Main.java:19)
	at CheckedExceptions.main(Main.java:60)
Caused by: L4Exception: L3Exception: L2Exception: L1Exception
	at CheckedExceptions.doSomethingL4(Main.java:29)
	at CheckedExceptions.doSomethingL5(Main.java:16)
	... 1 more
Caused by: L3Exception: L2Exception: L1Exception
	at CheckedExceptions.doSomethingL3(Main.java:39)
	at CheckedExceptions.doSomethingL4(Main.java:26)
	... 2 more
Caused by: L2Exception: L1Exception
	at CheckedExceptions.doSomethingL2(Main.java:49)
	at CheckedExceptions.doSomethingL3(Main.java:37)
	... 3 more
Caused by: L1Exception
	at CheckedExceptions.doSomethingL1(Main.java:55)
	at CheckedExceptions.doSomethingL2(Main.java:45)
	... 4 more