// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
public class TryResTricky17 {
    public static void main(String[] args) throws Exception {
        try (MyRes r = new MyRes()) {
            r.test();
        } catch(Exception ex) {
            System.out.println("catch of: " + ex.getMessage());
            for(Throwable t : ex.getSuppressed()) {
                System.out.println("suppressed: " + t.getMessage());
            }
        } finally {
            System.out.println("traditional finally");
        }
    }
}

class MyRes implements AutoCloseable {
    public MyRes() {
        System.out.println("constuctor called");
    }
    public void test() throws Exception {
        System.out.println("test called - will throw exception");
        throw new Exception("exception in test");
    }
    public void close() throws Exception {
        System.out.println("close called - will throw exception");
        throw new Exception("exception in close");
    }
}
