class MyException extends Exception {} class Foo { public static void main(String[] args) { try { bar(); } catch (Exception e) { if (e instanceof MyException) { return; } if (e instanceof RuntimeException) { return; } e.printStackTrace(); } } private static void bar() throws MyException { } }