public void RefreshExchangeRates() { if (PerksConfiguration.PerksEnabled && PerksConfiguration.ShowExchangeRates) { try { SellPrices = new Blockchain.ApiContext().GetExchangeInformation(); } catch (Exception ex) { //don't crash if website cannot be resolved or JSON cannot be parsed if ((ex is WebException) || (ex is InvalidCastException) || (ex is FormatException)) { if (ApplicationConfiguration.ShowApiErrors) ShowExchangeApiErrorNotification(ex); return; } throw; } } }
private void ShowExchangeApiErrorNotification(Exception ex) { ExchangeApi.IApiContext apiContext = new Blockchain.ApiContext(); string apiUrl = apiContext.GetApiUrl(); string apiName = apiContext.GetApiName(); string summary = String.Format("Error parsing the {0} JSON API", apiName); string details = ex.Message; PostNotification(ex.Message, String.Format(summary, apiName), () => { MessageBoxShow(String.Format("{0}: {1}", summary, details), "Error", PromptButtons.OK, PromptIcon.Error); }, NotificationKind.Warning, apiUrl); }