Added error handling to Initialize method in Win10Plugin

This pull request adds more robust error handling to the Initialize method in the Win10Plugin class. The changes include:

1. Added a try-catch block to the Initialize method to catch and log any exceptions that occur during initialization.

2. Enhanced the logging of exceptions to include not only the error message but also the entire error content, including the stack trace. This change makes debugging easier by providing more context when an error occurs.
This commit is contained in:
BenjaminS 2023-05-30 17:05:21 +03:00 committed by GitHub
commit 92528efaf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,6 +61,8 @@ namespace Greenshot.Plugin.Win10
/// </summary>
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
public bool Initialize()
{
try
{
// Here we check if the build version of Windows is actually what we support
if (!WindowsVersion.IsWindows10BuildOrLater(17763))
@ -78,8 +80,15 @@ namespace Greenshot.Plugin.Win10
// Add the destinations
SimpleServiceProvider.Current.AddService<IDestination>(new Win10OcrDestination());
SimpleServiceProvider.Current.AddService<IDestination>(new Win10ShareDestination());
return true;
}
catch (Exception e)
{
Log.Error("Failed to initialize Win10Plugin. Error: " + e.ToString(), e);
return false;
}
}
public void Shutdown()
{