Using blocks to handle errors