exceptions handling in main function