mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
Add log for cmd pal ext to trace exceptions (#39326)
* Add log to trace error for apps. * Add bookmark log * registry exception log * fix * Added logger for cmdpal extensions. Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> * remove noise * Update Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> * change log level * change level * Fix comments * Fixed comments. Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> * Resolve comments Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> --------- Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com> Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Resources;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Registry.Classes;
|
||||
using Microsoft.CmdPal.Ext.Registry.Helpers;
|
||||
using Microsoft.CmdPal.Ext.Registry.Properties;
|
||||
@@ -37,7 +38,7 @@ internal sealed partial class OpenKeyInEditorCommand : InvokableCommand
|
||||
RegistryHelper.OpenRegistryKey(entry.Key?.Name ?? entry.KeyPath);
|
||||
return true;
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception)
|
||||
catch (System.ComponentModel.Win32Exception ex)
|
||||
{
|
||||
// TODO GH #118 We need a convenient way to show errors to a user
|
||||
// MessageBox.Show(
|
||||
@@ -45,13 +46,13 @@ internal sealed partial class OpenKeyInEditorCommand : InvokableCommand
|
||||
// Resources.OpenInRegistryEditorAccessExceptionTitle,
|
||||
// MessageBoxButton.OK,
|
||||
// MessageBoxImage.Error);
|
||||
Logger.LogError(ex.Message);
|
||||
return false;
|
||||
}
|
||||
#pragma warning disable CS0168, IDE0059
|
||||
catch (Exception exception)
|
||||
{
|
||||
// TODO GH #108: Logging
|
||||
// Log.Exception("Error on opening Windows registry editor", exception, typeof(Main));
|
||||
Logger.LogError(exception.Message);
|
||||
return false;
|
||||
}
|
||||
#pragma warning restore CS0168, IDE0059
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Registry.Classes;
|
||||
using Microsoft.CmdPal.Ext.Registry.Constants;
|
||||
using Microsoft.CmdPal.Ext.Registry.Properties;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using ManagedCommon;
|
||||
using Microsoft.CmdPal.Ext.Registry.Classes;
|
||||
using Microsoft.CmdPal.Ext.Registry.Commands;
|
||||
using Microsoft.CmdPal.Ext.Registry.Constants;
|
||||
@@ -96,6 +96,7 @@ internal static class ResultHelper
|
||||
}
|
||||
catch (Exception valueException)
|
||||
{
|
||||
Logger.LogError(valueException.Message);
|
||||
var registryEntry = new RegistryEntry(key.Name, valueException);
|
||||
|
||||
resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry))
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<PackageReference Include="System.ServiceProcess.ServiceController" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||
<ProjectReference Include="..\..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user