fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.sql.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main(String[] args) {
  12. SQLException insertEx = null;
  13. try (AC ac = new AC()) {
  14. try {
  15. throw new SQLException("insert");
  16. } catch (SQLException e) {
  17. insertEx = e;
  18. throw new SQLException("rollback");
  19. }
  20. } catch (SQLException e) {
  21. Error error = new Error("insert failed", insertEx);
  22. error.addSuppressed(e);
  23. throw error;
  24. }
  25. }
  26.  
  27. private static class AC implements AutoCloseable {
  28. @Override
  29. public void close() throws SQLException {
  30. throw new SQLException("close");
  31. }
  32. }
  33. }
Runtime error #stdin #stdout #stderr 0.08s 33424KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.Error: insert failed
	at Ideone.main(Main.java:21)
	Suppressed: java.sql.SQLException: rollback
		at Ideone.main(Main.java:18)
		Suppressed: java.sql.SQLException: close
			at Ideone$AC.close(Main.java:30)
			at Ideone.main(Main.java:13)
Caused by: java.sql.SQLException: insert
	at Ideone.main(Main.java:15)