From 0efdc9454845661a411739fc3fdc5e58e1bfae39 Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Thu, 23 Jan 2025 17:40:52 +0000 Subject: [PATCH] [PTRun][Calculator]Error check when loading trigonometry mode (#37033) --- .../Main.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Main.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Main.cs index cc1a61e000..7b109fbed9 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Main.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Main.cs @@ -13,6 +13,7 @@ using ManagedCommon; using Microsoft.PowerToys.Run.Plugin.Calculator.Properties; using Microsoft.PowerToys.Settings.UI.Library; using Wox.Plugin; +using Wox.Plugin.Logger; namespace Microsoft.PowerToys.Run.Plugin.Calculator { @@ -212,8 +213,18 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator var optionReplaceInput = settings.AdditionalOptions.FirstOrDefault(x => x.Key == ReplaceInput); replaceInput = optionReplaceInput?.Value ?? replaceInput; - var optionTrigMode = settings.AdditionalOptions.FirstOrDefault(x => x.Key == TrigMode); - trigMode = (CalculateEngine.TrigMode)int.Parse(optionTrigMode.ComboBoxValue.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); + try + { + var optionTrigMode = settings.AdditionalOptions.FirstOrDefault(x => x.Key == TrigMode); + if (optionTrigMode != null) + { + trigMode = (CalculateEngine.TrigMode)int.Parse(optionTrigMode.ComboBoxValue.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); + } + } + catch (Exception ex) + { + Log.Exception("Error while trying to load Trigonometry Mode setting: {ex.Message}", ex, GetType()); + } } _inputUseEnglishFormat = inputUseEnglishFormat;