Corrected exception handling.