From cb449667794ddcd5b1e421ca2a7cae219e1b788c Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Thu, 22 Dec 2022 21:22:56 +0800 Subject: [PATCH] Catch exceptions during shortcut expansion --- Flow.Launcher/ViewModel/MainViewModel.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 09bba6e5c5e..eee7e453a73 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -769,8 +769,16 @@ private Query ConstructQuery(string queryText, IEnumerable { foreach (var shortcut in builtInShortcuts) { - queryBuilder.Replace(shortcut.Key, shortcut.Expand()); - queryBuilderTmp.Replace(shortcut.Key, shortcut.Expand()); + try + { + var expansion = shortcut.Expand(); + queryBuilder.Replace(shortcut.Key, expansion); + queryBuilderTmp.Replace(shortcut.Key, expansion); + } + catch (Exception e) + { + Log.Exception($"{nameof(MainViewModel)}.{nameof(ConstructQuery)}|Error when expanding shortcut {shortcut.Key}", e); + } } });