Wrap loop in try block.