Improve error handling

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Jack Ye 2026-02-21 20:11:49 +08:00 committed by GitHub
parent 9fa4c37109
commit 001101bb81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
}
}
}
}