Skip to content

Commit f6eefd3

Browse files
committed
catch exceptions loading news feed
1 parent 7fd0cf9 commit f6eefd3

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

AvalonStudio/AvalonStudio.Controls.Standard/WelcomeScreen/WelcomeScreenViewModel.cs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,39 +116,46 @@ private async void LoadNewsFeed()
116116
// RSS Releated
117117
var rssurl = @"http://go.microsoft.com/fwlink/?linkid=84795&clcid=409";
118118

119-
using (var reader = XmlReader.Create(rssurl))
119+
try
120120
{
121-
var feedReader = new RssFeedReader(reader);
122-
123-
while (await feedReader.Read())
121+
using (var reader = XmlReader.Create(rssurl))
124122
{
125-
switch (feedReader.ElementType)
123+
var feedReader = new RssFeedReader(reader);
124+
125+
while (await feedReader.Read())
126126
{
127-
case SyndicationElementType.Item:
128-
var syndicationItem = await feedReader.ReadItem();
127+
switch (feedReader.ElementType)
128+
{
129+
case SyndicationElementType.Item:
130+
var syndicationItem = await feedReader.ReadItem();
129131

130-
var content = syndicationItem.Description;
132+
var content = syndicationItem.Description;
131133

132-
int maxCharCount = 150;
134+
int maxCharCount = 150;
133135

134-
if (content.Length >= maxCharCount)
135-
{
136-
content = content.StripHTML().Truncate(maxCharCount, "...");
137-
}
136+
if (content.Length >= maxCharCount)
137+
{
138+
content = content.StripHTML().Truncate(maxCharCount, "...");
139+
}
138140

139-
var link = syndicationItem.Links.LastOrDefault();
140-
var url = "";
141+
var link = syndicationItem.Links.LastOrDefault();
142+
var url = "";
141143

142-
if (link != null)
143-
{
144-
url = link.Uri.AbsoluteUri;
145-
}
144+
if (link != null)
145+
{
146+
url = link.Uri.AbsoluteUri;
147+
}
146148

147-
_newsFeed.Add(new NewsFeedViewModel(url, content, syndicationItem.Categories.FirstOrDefault()?.Name, syndicationItem.Contributors.FirstOrDefault()?.Name, syndicationItem.Title));
148-
break;
149+
_newsFeed.Add(new NewsFeedViewModel(url, content, syndicationItem.Categories.FirstOrDefault()?.Name, syndicationItem.Contributors.FirstOrDefault()?.Name, syndicationItem.Title));
150+
break;
151+
}
149152
}
150153
}
151154
}
155+
catch (Exception)
156+
{
157+
158+
}
152159
}
153160

154161
private async void LoadVideoFeed()

0 commit comments

Comments
 (0)