From 4a0f126c34b16ee6aa478faa4cdea98eea72c7a3 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 14 Aug 2025 14:39:41 +0800 Subject: [PATCH 1/5] Use ShowMsgError instead of ShowMsgBox --- Flow.Launcher/PublicAPIInstance.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index e0ed105cff9..37bc16d58f1 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -382,21 +382,17 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null catch (Win32Exception ex) when (ex.NativeErrorCode == 2) { LogError(ClassName, "File Manager not found"); - ShowMsgBox( + ShowMsgError( string.Format(GetTranslation("fileManagerNotFound"), ex.Message), - GetTranslation("fileManagerNotFoundTitle"), - MessageBoxButton.OK, - MessageBoxImage.Error + GetTranslation("fileManagerNotFoundTitle") ); } catch (Exception ex) { LogException(ClassName, "Failed to open folder", ex); - ShowMsgBox( + ShowMsgError( string.Format(GetTranslation("folderOpenError"), ex.Message), - GetTranslation("errorTitle"), - MessageBoxButton.OK, - MessageBoxImage.Error + GetTranslation("errorTitle") ); } } @@ -424,11 +420,9 @@ private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false) { var tabOrWindow = browserInfo.OpenInTab ? "tab" : "window"; LogException(ClassName, $"Failed to open URL in browser {tabOrWindow}: {path}, {inPrivate ?? browserInfo.EnablePrivate}, {browserInfo.PrivateArg}", e); - ShowMsgBox( + ShowMsgError( GetTranslation("browserOpenError"), - GetTranslation("errorTitle"), - MessageBoxButton.OK, - MessageBoxImage.Error + GetTranslation("errorTitle") ); } } From c00d8db5ade73f815507bfe9949c4e3bf1d76263 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 14 Aug 2025 14:39:58 +0800 Subject: [PATCH 2/5] Handle E_ABORT --- Flow.Launcher/PublicAPIInstance.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 37bc16d58f1..002e3c58bf5 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Net; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -379,6 +380,21 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null explorer.Start(); } } + catch (COMException ex) when (ex.ErrorCode == unchecked((int)0x80004004)) + { + /* + * The COMException with HResult 0x80004004 is E_ABORT (operation aborted). + * Shell APIs often return this when the operation is canceled or the shell cannot complete it cleanly. + * It most likely comes from Win32Helper.OpenFolderAndSelectFile(targetPath). + * Typical triggers: + * The target file/folder was deleted/moved between computing targetPath and the shell call. + * The folder is on an offline network/removable drive. + * Explorer is restarting/busy and aborts the request. + * A selection request to a new/closing Explorer window is canceled. + * Because it is commonly user- or environment-driven and not actionable, + * we should treat it as expected noise and ignore it to avoid bothering users. + */ + } catch (Win32Exception ex) when (ex.NativeErrorCode == 2) { LogError(ClassName, "File Manager not found"); From cdd5bf1a763f2bf902d627d465624390e7a67495 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 14 Aug 2025 14:51:50 +0800 Subject: [PATCH 3/5] Swap title/subtitle for ShowMsgError --- Flow.Launcher/PublicAPIInstance.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 002e3c58bf5..38ca1814757 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -399,16 +399,16 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null { LogError(ClassName, "File Manager not found"); ShowMsgError( - string.Format(GetTranslation("fileManagerNotFound"), ex.Message), - GetTranslation("fileManagerNotFoundTitle") + GetTranslation("fileManagerNotFoundTitle"), + string.Format(GetTranslation("fileManagerNotFound"), ex.Message) ); } catch (Exception ex) { LogException(ClassName, "Failed to open folder", ex); ShowMsgError( - string.Format(GetTranslation("folderOpenError"), ex.Message), - GetTranslation("errorTitle") + GetTranslation("errorTitle"), + string.Format(GetTranslation("folderOpenError"), ex.Message) ); } } @@ -437,8 +437,8 @@ private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false) var tabOrWindow = browserInfo.OpenInTab ? "tab" : "window"; LogException(ClassName, $"Failed to open URL in browser {tabOrWindow}: {path}, {inPrivate ?? browserInfo.EnablePrivate}, {browserInfo.PrivateArg}", e); ShowMsgError( - GetTranslation("browserOpenError"), - GetTranslation("errorTitle") + GetTranslation("errorTitle"), + GetTranslation("browserOpenError") ); } } From 7264f5493f8a16bc36cfbc769dff3b5e232d0a92 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 14 Aug 2025 18:34:03 +0800 Subject: [PATCH 4/5] Use ShowMsgError for plugin load fail message --- Flow.Launcher.Core/Plugin/PluginsLoader.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginsLoader.cs b/Flow.Launcher.Core/Plugin/PluginsLoader.cs index 9d511297e3e..fbd0d07be9a 100644 --- a/Flow.Launcher.Core/Plugin/PluginsLoader.cs +++ b/Flow.Launcher.Core/Plugin/PluginsLoader.cs @@ -126,10 +126,9 @@ private static IEnumerable DotNetPlugins(List source _ = Task.Run(() => { - API.ShowMsgBox($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" + - $"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" + - API.GetTranslation("referToLogs"), string.Empty, - MessageBoxButton.OK, MessageBoxImage.Warning); + API.ShowMsgError($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" + + $"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" + + API.GetTranslation("referToLogs")); }); } From 556dce9bed5345ab27679ba42ebe9fd258378c05 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 14 Aug 2025 19:22:03 +0800 Subject: [PATCH 5/5] Remove unnecessary Task.Run --- Flow.Launcher.Core/Plugin/PluginsLoader.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginsLoader.cs b/Flow.Launcher.Core/Plugin/PluginsLoader.cs index fbd0d07be9a..e9e5ee367cb 100644 --- a/Flow.Launcher.Core/Plugin/PluginsLoader.cs +++ b/Flow.Launcher.Core/Plugin/PluginsLoader.cs @@ -124,12 +124,9 @@ private static IEnumerable DotNetPlugins(List source API.GetTranslation("pluginsHaveErrored") : API.GetTranslation("pluginHasErrored"); - _ = Task.Run(() => - { - API.ShowMsgError($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" + - $"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" + - API.GetTranslation("referToLogs")); - }); + API.ShowMsgError($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" + + $"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" + + API.GetTranslation("referToLogs")); } return plugins;