using future-proof syntax for exception catching