Use exception to handle errors.