Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit c2231ab

Browse files
RGrabichlerGemaTechnikPTKu
authored
Added Try-Catch Block to RogerAllMessages() (#608)
* Added Try-Catch Block to RogerAllMessages() in TcoDiagnosticsViewModel.cs because i got Exeption with NoElements * rg fix * removes accidentally copied file form TcoComponent --------- Co-authored-by: Roman <roman.grabichler@gema-technik.de> Co-authored-by: Peter <61538034+PTKu@users.noreply.github.com>
1 parent d0970cf commit c2231ab

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

src/TcoCore/src/TcOpen.Inxton.TcoCore.Blazor/TcoDiagnostics/TcoDiagnosticsViewModel.cs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public eMessageCategory MinMessageCategoryFilter
5050
public static eMessageCategory SetDefaultCategory(eMessageCategory item) => DefaulCategory = item;
5151

5252
public static eMessageCategory DefaulCategory { get; set; } = eMessageCategory.Info;
53-
53+
5454

5555
bool diagnosticsRunning;
5656

@@ -70,7 +70,7 @@ internal set
7070
SetProperty(ref diagnosticsRunning, value);
7171
}
7272
}
73-
73+
7474
/// <summary>
7575
/// Updates messages of diagnostics view.
7676
/// </summary>
@@ -80,7 +80,7 @@ internal void UpdateMessages()
8080
{
8181
return;
8282
}
83-
83+
8484
lock (updatemutex)
8585
{
8686

@@ -91,10 +91,10 @@ internal void UpdateMessages()
9191
MessageDisplay = _tcoObject.MessageHandler.GetActiveMessages().Where(p => p.CategoryAsEnum >= MinMessageCategoryFilter)
9292
.OrderByDescending(p => p.Category)
9393
.OrderBy(p => p.TimeStamp);
94-
94+
9595

9696
}).Wait();
97-
97+
9898
DiagnosticsRunning = false;
9999

100100
}
@@ -156,17 +156,28 @@ public void RogerAllMessages()
156156
{
157157
lock (updatemutex)
158158
{
159-
TcoAppDomain.Current.Logger.Information("All message acknowledged {@payload}", new { rootObject = _tcoObject.HumanReadable, rootSymbol = _tcoObject.Symbol });
160-
foreach (var item in MessageDisplay.Where(p => p.Pinned))
159+
try
161160
{
162-
item.OnlinerMessage.Pinned.Cyclic = false;
163-
TcoAppDomain.Current.Logger.Information("Message acknowledged {@message}", new { Text = item.Text, Category = item.CategoryAsEnum });
161+
162+
TcoAppDomain.Current.Logger.Information("All message acknowledged {@payload}", new { rootObject = _tcoObject.HumanReadable, rootSymbol = _tcoObject.Symbol });
163+
foreach (var item in MessageDisplay.Where(p => p.Pinned))
164+
{
165+
item.OnlinerMessage.Pinned.Cyclic = false;
166+
TcoAppDomain.Current.Logger.Information("Message acknowledged {@message}", new { Text = item.Text, Category = item.CategoryAsEnum });
167+
}
168+
169+
}
170+
catch (Exception ex)
171+
{
172+
// Log the error message
173+
TcoAppDomain.Current.Logger.Error("An error occurred while acknowledging messages: {@error}", ex);
174+
// Throw the exception to be handled by the caller
175+
throw;
164176
}
165177
}
166-
167178
}
179+
168180
public IVortexObject AffectedObject { get; set; }
169-
170181

171182
}
172183

0 commit comments

Comments
 (0)