Skip to content

Commit 7d54f16

Browse files
committed
fix #3: Fire the error when click the tab.
1 parent 6ed143a commit 7d54f16

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

  • Community.PowerToys.Run.Plugin.HttpStatusCodes

Community.PowerToys.Run.Plugin.HttpStatusCodes/Main.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using ManagedCommon;
22
using System;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
45
using Wox.Infrastructure;
56
using Wox.Plugin;
67
using BrowserInfo = Wox.Plugin.Common.DefaultBrowserInfo;
@@ -56,8 +57,19 @@ public List<Result> Query(Query query)
5657
IcoPath = IconPath,
5758
Action = _ =>
5859
{
59-
if (Helper.OpenCommandInShell(BrowserInfo.Path, BrowserInfo.ArgumentsPattern,
60-
httpStatus?.DefinedIn)) return true;
60+
try {
61+
if (Helper.OpenCommandInShell(BrowserInfo.Path, BrowserInfo.ArgumentsPattern,
62+
httpStatus?.DefinedIn)) return true;
63+
} catch (InvalidOperationException) {
64+
// See https://github.com/grzhan/HttpStatusCodePowerToys/issues/3
65+
// In some operating systems (perhaps Windows 10),
66+
// the DefaultBrowserInfo fails to return the correct browser path.
67+
// Therefore, attempt to launch the browser directly based on the URL.
68+
Process.Start(new ProcessStartInfo(httpStatus!.DefinedIn)
69+
{
70+
UseShellExecute = true
71+
});
72+
}
6173
ErrorHandler.OnPluginError();
6274
return false;
6375
},

0 commit comments

Comments
 (0)