Handling checked exception in method