Updated rescue to find exception type