From e14609cbca980bb7103c86ae977327dfec8ac177 Mon Sep 17 00:00:00 2001 From: vanzue Date: Mon, 12 May 2025 09:45:44 +0800 Subject: [PATCH] Fix comments --- .../cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs | 10 +++++++++- .../ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs | 1 - .../Programs/PackageWrapper.cs | 1 - .../Helpers/RegistryHelper.cs | 2 -- .../Helpers/ResultHelper.cs | 1 - .../Helpers/AvailableResultsList.cs | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs index 6cb416f271..cb57086cb3 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs @@ -2,6 +2,7 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Diagnostics; using System.Threading.Tasks; using ManagedCommon; @@ -48,7 +49,14 @@ internal sealed partial class AppCommand : InvokableCommand // const ActivateOptions noFlags = ActivateOptions.None; await Task.Run(() => { - Process.Start(new ProcessStartInfo(path) { UseShellExecute = true }); + try + { + Process.Start(new ProcessStartInfo(path) { UseShellExecute = true }); + } + catch (System.Exception ex) + { + Logger.LogError(ex.Message); + } }); } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs index 9f3f38a43f..57c9175d4d 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using ManagedCommon; using Microsoft.CommandPalette.Extensions; using Microsoft.CommandPalette.Extensions.Toolkit; using Windows.Storage.Streams; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs index 00f33d1efd..108195390e 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs @@ -52,7 +52,6 @@ public class PackageWrapper : IPackage } catch (Exception e) when (e is ArgumentException || e is FileNotFoundException || e is DirectoryNotFoundException) { - Logger.LogError(e.Message); return new PackageWrapper( package.Id.Name, package.Id.FullName, diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs index 6e3eee7ef1..9cd30b2bea 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs @@ -201,14 +201,12 @@ internal static class RegistryHelper } catch (Exception exception) { - Logger.LogError(exception.Message); list.Add(new RegistryEntry($"{parentKey.Name}\\{subKey}", exception)); } } } catch (Exception ex) { - Logger.LogError(ex.Message); list.Add(new RegistryEntry(parentKey.Name, ex)); } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs index 16e6faab9c..d607ce6b23 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs @@ -141,7 +141,6 @@ internal static class ResultHelper } catch (Exception exception) { - Logger.LogError(exception.Message); var registryEntry = new RegistryEntry(key.Name, exception); resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry)) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs index 2b52ca57ba..ee14fdb855 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs @@ -112,9 +112,9 @@ internal static class AvailableResultsList } catch (Exception ex) { - Logger.LogError($"Unable to format date time with format: {value}. Error: {ex.Message}"); if (!containsCustomSyntax) { + Logger.LogError($"Unable to format date time with format: {value}. Error: {ex.Message}"); throw; } else