Handling exceptions using try and catch