Fixed failure to catch right exception.