Use exception method to log errors