Why is exception being swallowed here?