handle internet errors nicer

This commit is contained in:
Matthew D. Groves 2011-04-30 13:31:47 -04:00
parent 63c387220d
commit 3d2b33e3fc
6 changed files with 30 additions and 5 deletions

View file

@ -84,11 +84,18 @@ namespace MonoStockPortfolio.Activites.EditPositionScreen
private string ValidateTicker(string ticker)
{
if (_stockService.IsValidTicker(ticker))
try
{
return string.Empty;
if (_stockService.IsValidTicker(ticker))
{
return string.Empty;
}
return "Invalid Ticker Name";
}
catch (Exception ex)
{
return "Unable to load stock information from the web";
}
return "Invalid Ticker Name";
}
private string ValidateNotRepeatTicker(string ticker)

View file

@ -13,5 +13,6 @@ namespace MonoStockPortfolio.Activites.PortfolioScreen
void UpdateHeader(IEnumerable<StockDataItem> configItems);
void ShowProgressDialog(string loadingMessage);
void HideProgressDialog();
void FlashMessage(string toastMessage);
}
}

View file

@ -110,6 +110,12 @@ namespace MonoStockPortfolio.Activites.PortfolioScreen
}
}
[OnGuiThread]
public void FlashMessage(string toastMessage)
{
this.LongToast(toastMessage);
}
#endregion
private void WireUpEvents()

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Android.Runtime;
@ -105,7 +106,16 @@ namespace MonoStockPortfolio.Activites.PortfolioScreen
{
_currentView.ShowProgressDialog("Loading...Please wait...");
_positions = GetPositions();
try
{
_positions = GetPositions();
}
catch (Exception)
{
_currentView.FlashMessage("Unable to load stock data from the web");
_positions = new List<PositionResultsViewModel>();
}
if (_positions.Any())
{
_currentView.RefreshList(_positions, GetConfigItems());

View file

@ -19,6 +19,7 @@
<AndroidApplication>true</AndroidApplication>
<AndroidStoreUncompressedFileExtensions />
<TargetFrameworkVersion>v2.1</TargetFrameworkVersion>
<MandroidI18n />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
// Runtime Version:4.0.30319.225
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.