Fix minor bug introduced when refactoring exception catching