diff --git a/Core.Web.WarThunder/Helpers/ThunderSkillParser.cs b/Core.Web.WarThunder/Helpers/ThunderSkillParser.cs index 309b32d5..aee47d9c 100644 --- a/Core.Web.WarThunder/Helpers/ThunderSkillParser.cs +++ b/Core.Web.WarThunder/Helpers/ThunderSkillParser.cs @@ -54,11 +54,18 @@ public void Load() var url = Settings.ThunderSkillUrl; - LogDebug(ECoreLogMessage.Reading.Format(url)); + if (string.IsNullOrWhiteSpace(url)) { - _mainHtmlNode = GetHtmlDocumentNode(url); + LogWarn("ThunderSkill (TS) URL is empty. Makes sure to copy TS related settings from the default \"Client.Wpf.Settings.xml\"."); + } + else + { + LogDebug(ECoreLogMessage.Reading.Format(url)); + { + _mainHtmlNode = GetHtmlDocumentNode(url); + } + LogDebug(ECoreLogMessage.FinishedReading.Format(url)); } - LogDebug(ECoreLogMessage.FinishedReading.Format(url)); IsLoaded = true; } @@ -90,7 +97,7 @@ private IDictionary GetVehicleUsage(string tableXPath) if (string.IsNullOrWhiteSpace(tableXPath)) return vehicleUsageRecords; - var table = _mainHtmlNode.SelectSingleNode(tableXPath); + var table = _mainHtmlNode?.SelectSingleNode(tableXPath); if (table is HtmlNode) { diff --git a/Core.Web/Helpers/HtmlParser.cs b/Core.Web/Helpers/HtmlParser.cs index 1139a3d9..29c5fae3 100644 --- a/Core.Web/Helpers/HtmlParser.cs +++ b/Core.Web/Helpers/HtmlParser.cs @@ -33,6 +33,9 @@ public HtmlNode GetHtmlDocumentNode(string url, int retryAttempts = EInteger.Num if (retryAttempts.IsZero()) throw new TimeoutException(EWebLogMessage.FailedToRead.Format(url), internalException); + if (string.IsNullOrWhiteSpace(url)) + throw new ArgumentException($"\"{nameof(url)}\" is null or empty."); + try { return new HtmlWeb()