mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
Add try-catch to desktop notification (#839)
This commit is contained in:
@@ -242,18 +242,29 @@ namespace VRCX
|
|||||||
/// <param name="Image">The optional image to display in the notification.</param>
|
/// <param name="Image">The optional image to display in the notification.</param>
|
||||||
public void DesktopNotification(string BoldText, string Text = "", string Image = "")
|
public void DesktopNotification(string BoldText, string Text = "", string Image = "")
|
||||||
{
|
{
|
||||||
ToastContentBuilder builder = new ToastContentBuilder();
|
try
|
||||||
|
{
|
||||||
if (Uri.TryCreate(Image, UriKind.Absolute, out Uri uri))
|
ToastContentBuilder builder = new ToastContentBuilder();
|
||||||
builder.AddAppLogoOverride(uri);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(BoldText))
|
if (Uri.TryCreate(Image, UriKind.Absolute, out Uri uri))
|
||||||
builder.AddText(BoldText);
|
builder.AddAppLogoOverride(uri);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Text))
|
|
||||||
builder.AddText(Text);
|
|
||||||
|
|
||||||
builder.Show();
|
if (!string.IsNullOrEmpty(BoldText))
|
||||||
|
builder.AddText(BoldText);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Text))
|
||||||
|
builder.AddText(Text);
|
||||||
|
|
||||||
|
builder.Show();
|
||||||
|
}
|
||||||
|
catch (System.AccessViolationException ex)
|
||||||
|
{
|
||||||
|
logger.Warn(ex, "Unable to send desktop notification");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error(ex, "Unknown error when sending desktop notification");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user