예제 #1
0
        public async Task <bool> UpdateData()
        {
            var json = await dataFetcher.UpdateData();

            try
            {
                telemetry = JsonSerializer.Deserialize <TelemetryStorage>(json, jsonSerializerOptions);
                await dataSaver.SaveTelemetryToFile(telemetry);
            }
            catch (ArgumentNullException ex)
            {
                string EventMessage = "An error occurred in TelemetryParser while updating data. An object to populate with values from JSON file was null.";
                await EventLogger.LogExceptionForUserAndToFile(EventMessage, ex);

                await EventLogger.LogExceptionToFile(EventMessage, ex.Message, ex.StackTrace);

                return(false);
            }
            catch (JsonException ex)
            {
                string EventMessage = "An error occurred in TelemetryParser while updating data. Downloaded JSON file is invalid.";
                await EventLogger.LogExceptionForUserAndToFile(EventMessage, ex);

                return(false);
            }
            catch (Exception ex)
            {
                string EventMessage = "An unknown error occurred in TelemetryParser while updating data. ";
                await EventLogger.LogExceptionForUserAndToFile(EventMessage, ex);

                return(false);
            }

            return(true);
        }