private async Task <FeatureToggleResponse> GetToggleResponse(HttpResponseMessage response) { _etag = response.Headers.ETag?.Tag; var content = await response.Content.ReadAsStringAsync(); var toggles = new ToggleCollection(); try { toggles = JsonToggleParser.FromJson(content); } catch (Exception ex) { Logger.WarnException("received toggles failed", ex); } return(FeatureToggleResponse.Changed(toggles)); }
public ToggleCollection Read() { Logger.Info("Unleash will try to load feature toggle states from temporary backup"); try { var json = File.ReadAllText(_backupFile); return(JsonToggleParser.FromJson(json)); } catch (FileNotFoundException) { Logger.Warn(" Unleash could not find the backup-file '" + _backupFile + "'. \n" + "This is expected behavior the first time unleash runs in a new environment."); } catch (UnauthorizedAccessException e) { Logger.WarnException("Failed to read backup file:'{File}'. Do not have the required permission", e, _backupFile); } catch (PathTooLongException e) { Logger.WarnException("Failed to read backup file:'{File}'. Path is more than 260 characters", e, _backupFile); } catch (ArgumentNullException e) { Logger.WarnException("Failed to read backup file:'{File}'. Path is null", e, _backupFile); } catch (ArgumentException e) { Logger.WarnException("Failed to read backup file:'{File}'. Invalid path", e, _backupFile); } catch (DirectoryNotFoundException e) { Logger.WarnException("Failed to read backup file:'{File}'. Directory not found", e, _backupFile); } catch (NotSupportedException e) { Logger.WarnException("Failed to read backup file:'{File}'. Path is in an invalid format", e, _backupFile); } catch (JsonException e) { Logger.WarnException("Failed to read backup file:'{}'", e, _backupFile); } return(ToggleCollection.EmptyCollection); }