From 001101bb813f96658630b88a00e247b3e510d11f Mon Sep 17 00:00:00 2001 From: Jack Ye Date: Sat, 21 Feb 2026 20:11:49 +0800 Subject: [PATCH] Improve error handling Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../UserSettings/DataLocation.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs b/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs index 2e23734d7..7b610d31a 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs @@ -59,8 +59,19 @@ namespace Flow.Launcher.Infrastructure.UserSettings if (Path.IsPathRooted(path)) return path; - // Resolve relative to ProgramDirectory - return Path.GetFullPath(Path.Combine(Constant.ProgramDirectory, path)); + // Resolve relative to ProgramDirectory, handling invalid path formats gracefully + try + { + return Path.GetFullPath(Path.Combine(Constant.ProgramDirectory, path)); + } + catch (Exception ex) when (ex is ArgumentException || + ex is NotSupportedException || + ex is PathTooLongException) + { + // If the path cannot be resolved (invalid characters, format, or too long), + // return the original path to avoid crashing the application. + return path; + } } } }