From bfd10f690324af0a30b7767817e04da8c4db3b47 Mon Sep 17 00:00:00 2001 From: dcog989 Date: Mon, 22 Sep 2025 13:37:22 +0100 Subject: [PATCH] Crash when opening non-existent file --- Flow.Launcher/PublicAPIInstance.cs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 6a8ee40f9..731c329e2 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -412,6 +412,14 @@ namespace Flow.Launcher private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false) { + if (uri.IsFile) + { + if (!File.Exists(uri.LocalPath) && !Directory.Exists(uri.LocalPath)) + { + ShowMsgError(GetTranslation("errorTitle"), $"File or directory not found: {uri.LocalPath}"); + return; + } + } if (forceBrowser || uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) { var browserInfo = _settings.CustomBrowser; @@ -441,13 +449,19 @@ namespace Flow.Launcher } else { - Process.Start(new ProcessStartInfo() + try { - FileName = uri.AbsoluteUri, - UseShellExecute = true - })?.Dispose(); - - return; + Process.Start(new ProcessStartInfo() + { + FileName = uri.AbsoluteUri, + UseShellExecute = true + })?.Dispose(); + } + catch (Exception e) + { + LogException(ClassName, $"Failed to open: {uri.AbsoluteUri}", e); + ShowMsgError(GetTranslation("errorTitle"), e.Message); + } } }