Skip to content

Commit

Permalink
Handle key printing exception to avoid app crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxhy committed Oct 28, 2024
1 parent 3336397 commit 1e7eafe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion KeyManager.Library.UI/KeyActionButtonsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace Leosac.KeyManager.Library.UI
/// </summary>
public partial class KeyActionButtonsControl : UserControl
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod()?.DeclaringType);

public KeyActionButtonsControl()
{
InitializeComponent();
Expand Down Expand Up @@ -128,7 +130,14 @@ private void BtnPrint_Click(object sender, RoutedEventArgs e)
var kcv = new KeyGen.KCV();
control.KeyChecksum = kcv.ComputeKCV(Key.Tags, Key.GetAggregatedValueAsString() ?? "", null);
}
printDialog.PrintVisual(control, "Leosac Key Manager - Key Printing");
try
{
printDialog.PrintVisual(control, "Leosac Key Manager - Key Printing");
}
catch(Exception ex)
{
log.Error("Key printing error.", ex);
}
}
}

Expand Down

0 comments on commit 1e7eafe

Please sign in to comment.