Corrected error message handling