Fixed type conversion error in exception handling