Skip to content

Commit

Permalink
fix: Notification code causing crash (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJosipovic authored Jan 15, 2025
1 parent e467d85 commit acedaad
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions src/KubeUI/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,37 +274,44 @@ public static void HandleException(ILogger logger, INotificationManager notifica
{
if (sendNotification)
{
if(ex is AggregateException aggregate)
try
{
foreach (var item in aggregate.InnerExceptions)
if (ex is AggregateException aggregate)
{
if (item is HttpOperationException opEx)
foreach (var item in aggregate.InnerExceptions)
{
var status = KubernetesYaml.Deserialize<V1Status>(opEx.Response.Content);
if (item is HttpOperationException opEx)
{
var status = KubernetesJson.Deserialize<V1Status>(opEx.Response.Content);

if (status != null)
if (status != null)
{
notificationManage.Show(new Notification(status.Reason, status.Message + "\n\n" + status?.Details?.Causes?.Select(x => x.Message).Aggregate((x, y) => x + "\n" + y) ?? "", type, TimeSpan.FromSeconds(30)));
}
}
else
{
notificationManage.Show(new Notification(status.Reason, status.Message + "\n\n" + status?.Details?.Causes?.Select(x => x.Message).Aggregate((x, y) => x + "\n" + y) ?? "", type, TimeSpan.FromSeconds(30)));
notificationManage.Show(new Notification(message, item.Message, type));
}
}
else
}
else if (ex is HttpOperationException opEx)
{
var status = KubernetesJson.Deserialize<V1Status>(opEx.Response.Content);

if (status != null)
{
notificationManage.Show(new Notification(message, item.Message, type));
notificationManage.Show(new Notification(status.Reason, status.Message + "\n\n" + status?.Details?.Causes?.Select(x => x.Message).Aggregate((x, y) => x + "\n" + y) ?? "", type, TimeSpan.FromSeconds(30)));
}
}
}
else if (ex is HttpOperationException opEx)
{
var status = KubernetesYaml.Deserialize<V1Status>(opEx.Response.Content);

if (status != null)
else
{
notificationManage.Show(new Notification(status.Reason, status.Message + "\n\n" + status?.Details?.Causes?.Select(x => x.Message).Aggregate((x, y) => x + "\n" + y) ?? "", type, TimeSpan.FromSeconds(30)));
notificationManage.Show(new Notification(message, ex.Message, type));
}
}
else
catch (Exception ex2)
{
notificationManage.Show(new Notification(message, ex.Message, type));
logger.LogError(ex2, "Error sending Notification");
}
}

Expand Down

0 comments on commit acedaad

Please sign in to comment.