Skip to content

Commit 653097e

Browse files
committed
Add try-catch sentence
1 parent fd3c658 commit 653097e

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

Flow.Launcher.Infrastructure/QuickSwitch/QuickSwitch.cs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -799,21 +799,29 @@ private static async Task<bool> NavigateDialogPathAsync(HWND hwnd, bool auto = f
799799
private static bool CheckPath(string path, out bool file)
800800
{
801801
file = false;
802-
// shell: and shell::: paths
803-
if (path.StartsWith("shell:", StringComparison.OrdinalIgnoreCase))
802+
try
803+
{
804+
// shell: and shell::: paths
805+
if (path.StartsWith("shell:", StringComparison.OrdinalIgnoreCase))
806+
{
807+
return true;
808+
}
809+
// file: URI paths
810+
var localPath = path.StartsWith("file:", StringComparison.OrdinalIgnoreCase)
811+
? new Uri(path).LocalPath
812+
: path;
813+
// Is folder?
814+
var isFolder = Directory.Exists(localPath);
815+
// Is file?
816+
var isFile = File.Exists(localPath);
817+
file = isFile;
818+
return isFolder || isFile;
819+
}
820+
catch (System.Exception e)
804821
{
805-
return true;
822+
Log.Exception(ClassName, "Failed to check path", e);
823+
return false;
806824
}
807-
// file: URI paths
808-
var localPath = path.StartsWith("file:", StringComparison.OrdinalIgnoreCase)
809-
? new Uri(path).LocalPath
810-
: path;
811-
// Is folder?
812-
var isFolder = Directory.Exists(localPath);
813-
// Is file?
814-
var isFile = File.Exists(localPath);
815-
file = isFile;
816-
return isFolder || isFile;
817825
}
818826

819827
private static IQuickSwitchDialogWindowTab GetDialogWindowTab(HWND hwnd)

0 commit comments

Comments
 (0)