From 0478d99aacd5403f6b8fea7cc58976643015801b Mon Sep 17 00:00:00 2001 From: Alekhya Date: Fri, 11 Sep 2020 13:04:25 -0700 Subject: [PATCH] To catch URI Format Exception in PT Run (#6580) * add a catch block for uri format exceptions * Added link to watson crash --- .../Programs/Win32Program.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs index 3e851ef008..2cb5604a85 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/Win32Program.cs @@ -376,7 +376,18 @@ namespace Microsoft.Plugin.Program.Programs if (line.StartsWith(urlPrefix, StringComparison.OrdinalIgnoreCase)) { urlPath = line.Substring(urlPrefix.Length); - Uri uri = new Uri(urlPath); + + try + { + Uri uri = new Uri(urlPath); + } + catch (UriFormatException e) + { + // To catch the exception if the uri cannot be parsed. + // Link to watson crash: https://watsonportal.microsoft.com/Failure?FailureSearchText=5f871ea7-e886-911f-1b31-131f63f6655b + ProgramLogger.LogException($"|Win32Program|InternetShortcutProgram|{urlPath}|url could not be parsed", e); + return new Win32Program() { Valid = false, Enabled = false }; + } // To filter out only those steam shortcuts which have 'run' or 'rungameid' as the hostname if (internetShortcutURLPrefixes.Match(urlPath).Success)