diff --git a/BrowseRouter/Actions.cs b/BrowseRouter/Actions.cs
new file mode 100644
index 0000000..f52734f
--- /dev/null
+++ b/BrowseRouter/Actions.cs
@@ -0,0 +1,18 @@
+namespace BrowseRouter;
+
+public static class Actions
+{
+ public static bool TryRun(Action a)
+ {
+ try
+ {
+ a();
+ return true;
+ }
+ catch (Exception e)
+ {
+ Log.Write($"{e}");
+ return false;
+ }
+ }
+}
diff --git a/BrowseRouter/BrowserService.cs b/BrowseRouter/BrowserService.cs
index 2796905..b2e0e3a 100644
--- a/BrowseRouter/BrowserService.cs
+++ b/BrowseRouter/BrowserService.cs
@@ -38,9 +38,14 @@ public async Task LaunchAsync(string url, string windowTitle)
Log.Write($"Launching {path} with args \"{args} {uri.OriginalString}\"");
string name = GetAppName(path);
- await notifier.NotifyAsync($"Opening {name}", $"URL: {url}");
- Process.Start(path, $"{args} \"{uri.OriginalString}\"");
+ if (!Actions.TryRun(() => Process.Start(path, $"{args} \"{uri.OriginalString}\"")))
+ {
+ await notifier.NotifyAsync($"Error", $"Could not open {name}. Please check the log for more details.");
+ return;
+ }
+
+ await notifier.NotifyAsync($"Opening {name}", $"URL: {url}");
}
catch (Exception e)
{
diff --git a/BrowseRouter/DefaultBrowserService.cs b/BrowseRouter/DefaultBrowserService.cs
index afa14a1..d90fb44 100644
--- a/BrowseRouter/DefaultBrowserService.cs
+++ b/BrowseRouter/DefaultBrowserService.cs
@@ -124,20 +124,9 @@ public async Task UnregisterAsync()
private void Unregister()
{
Log.Write("Unregistering...");
- Try(() => Registry.CurrentUser.DeleteSubKeyTree(AppKey, false));
- Try(() => _registerKey?.DeleteValue(_appID));
- Try(() => Registry.CurrentUser.DeleteSubKeyTree(UrlKey));
+ Actions.TryRun(() => Registry.CurrentUser.DeleteSubKeyTree(AppKey, false));
+ Actions.TryRun(() => _registerKey?.DeleteValue(_appID));
+ Actions.TryRun(() => Registry.CurrentUser.DeleteSubKeyTree(UrlKey));
Log.Write("Done");
}
-
- private static void Try(Action a)
- {
- try
- {
- a();
- }
- catch
- {
- }
- }
-}
+}
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
index bb1d6cd..b15f9c5 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,7 +6,7 @@
enable
enable
latest
- 0.12.6
+ 0.12.7
BrowseRouter
EnduraByte LLC 2024