Catch the exception and test its type directly