try { o.foo() } catch:(MyException e) { // handle exceptions of type MyException and derived }