fix(Program.cs): add try-catch block to handle potential errors when getting the foreground process
This commit is contained in:
@@ -246,11 +246,15 @@ namespace DD2Switcher {
|
||||
}
|
||||
|
||||
private static void TabToPrevious() {
|
||||
try {
|
||||
var foreground = GetForegroundProcess();
|
||||
if (!ProcessTracked(foreground.Id)) {
|
||||
Console.WriteLine("Foreground process not tracked, skipping");
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine($"Error setting foreground window: {e}");
|
||||
}
|
||||
|
||||
if (lastWindows.Count == 0) {
|
||||
Console.WriteLine("No previous window to switch to");
|
||||
|
Reference in New Issue
Block a user