From adac4478bb78802e8817b8e98b01eb2f91ff6ab8 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 16 Dec 2010 19:00:19 +0100 Subject: [PATCH] Handle exception when downloading children in TocEntry. --- .../Misc/HelpViewer/Source/Controls/TocEntry.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/AddIns/Misc/HelpViewer/Source/Controls/TocEntry.cs b/src/AddIns/Misc/HelpViewer/Source/Controls/TocEntry.cs index aeb19070c6..21702f702a 100644 --- a/src/AddIns/Misc/HelpViewer/Source/Controls/TocEntry.cs +++ b/src/AddIns/Misc/HelpViewer/Source/Controls/TocEntry.cs @@ -34,11 +34,17 @@ namespace MSHelpSystem.Controls client.DownloadStringCompleted += (_, e) => { - LoggingService.Debug(string.Format("Help 3.0: title \"{0}\"", Title)); - var children = XElement.Parse(e.Result); - Children = children.Elements("topic") - .Select(link => new TocEntry(link.Attribute("id").Value) { Title = link.Element("title").Value }) - .ToArray(); + try { + LoggingService.Debug(string.Format("Help 3.0: title \"{0}\"", Title)); + var children = XElement.Parse(e.Result); + Children = children.Elements("topic") + .Select(link => new TocEntry(link.Attribute("id").Value) { Title = link.Element("title").Value }) + .ToArray(); + } catch (TargetInvocationException ex) { + // Exception when fetching e.Result: + LoggingService.Warn(ex); + this.children = defaultChild; + } client.Dispose(); }; RaisePropertyChanged("Children");