class SwingException extends Exception {} class CloseException extends Exception {} class Door implements AutoCloseable { public void swing() throws Exception { System.out.println("The door is becoming unhinged!"); close(); throw new SwingException(); } public void close() throws Exception { System.out.println("The door is now closed."); throw new CloseException(); } }