Adding try catch to display error msg.