Skip to content

Commit

Permalink
Catch potential WebExceptions when retrieving CC.NET builds
Browse files Browse the repository at this point in the history
  • Loading branch information
steffen-wilke committed Feb 11, 2020
1 parent ed1c92c commit 5890655
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/Soloplan.WhatsON.CruiseControl/CruiseControlServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,27 @@ public async Task<List<CruiseControlBuild>> GetBuilds(string projectName, int li
var projectReportUrl = UrlHelper.GetAllBuildsUrl(this.baseUrl, projectName);
using (var client = new WebClient())
{
var html = client.DownloadString(projectReportUrl);
var doc = new HtmlDocument();
doc.LoadHtml(html);
var recentBuilds = doc.DocumentNode.SelectNodes("//table[@class='RecentBuildsPanel']/tr/td/a[@class]");
foreach (var b in recentBuilds.Take(limit))
try
{
var authority = new Uri(projectReportUrl).GetLeftPart(System.UriPartial.Authority);
var build = CruiseControlBuild.FromHtmlNode(b, authority);
if (build == null)
var html = client.DownloadString(projectReportUrl);
var doc = new HtmlDocument();
doc.LoadHtml(html);
var recentBuilds = doc.DocumentNode.SelectNodes("//table[@class='RecentBuildsPanel']/tr/td/a[@class]");
foreach (var b in recentBuilds.Take(limit))
{
continue;
var authority = new Uri(projectReportUrl).GetLeftPart(System.UriPartial.Authority);
var build = CruiseControlBuild.FromHtmlNode(b, authority);
if (build == null)
{
continue;
}

history.Add(build);
}

history.Add(build);
}
catch (WebException ex)
{
log.Error(ex);
}
}

Expand Down

0 comments on commit 5890655

Please sign in to comment.