[PreviewHandlers]Ignore telemetry exceptions (#28612)

This commit is contained in:
Jaime Bernardo
2023-09-19 15:41:17 +01:00
committed by GitHub
parent b471c98f7e
commit e09839dd6e
4 changed files with 65 additions and 9 deletions

View File

@@ -78,7 +78,13 @@ namespace Microsoft.PowerToys.PreviewHandler.Gcode
Resize += FormResized;
base.DoPreview(fs);
PowerToysTelemetry.Log.WriteEvent(new GcodeFilePreviewed());
try
{
PowerToysTelemetry.Log.WriteEvent(new GcodeFilePreviewed());
}
catch
{ // Should not crash if sending telemetry is failing. Ignore the exception.
}
}
catch (Exception ex)
{
@@ -148,7 +154,14 @@ namespace Microsoft.PowerToys.PreviewHandler.Gcode
/// <param name="dataSource">Stream reference to access source file.</param>
private void PreviewError<T>(Exception exception, T dataSource)
{
PowerToysTelemetry.Log.WriteEvent(new GcodeFilePreviewError { Message = exception.Message });
try
{
PowerToysTelemetry.Log.WriteEvent(new GcodeFilePreviewError { Message = exception.Message });
}
catch
{ // Should not crash if sending telemetry is failing. Ignore the exception.
}
Controls.Clear();
_infoBarAdded = true;
AddTextBoxControl(Properties.Resource.GcodeNotPreviewedError);