Added try{}catch(){} statement to make protect against accidental insertion into DB of data that was obtained after an error occured.