cleaned code

This commit is contained in:
2026-03-07 17:51:02 +01:00
parent 49aed2493a
commit 0e6caa136e
13 changed files with 39 additions and 33 deletions

View File

@@ -40,24 +40,26 @@ public class WorkerService : BackgroundService
private async Task HandleMessage<T>(T message, CancellationToken ct) where T : IMessage
{
Console.WriteLine($"*--------{message.GetType().Name}--------*");
try
{
await _dispatcher.Execute(message, ct);
Console.WriteLine($"OK: {message.GetType().Name}");
Console.WriteLine("OK!");
}
catch (ValidationException validationException)
{
var whiteboardId = message.GetWhiteboardId();
if (whiteboardId is not null)
if (message is IWhiteboardAwareContext)
{
var errorMessage = new ErrorMessage(whiteboardId.Value, validationException.ValidationErrors);
var whiteboardId = ((IWhiteboardAwareContext)message).GetWhiteboardId();
var errorMessage = new ErrorMessage(whiteboardId, validationException.ValidationErrors);
await _publisher.PublishAsync(errorMessage, ct);
}
Console.WriteLine("===Validation Exception: ");
Console.WriteLine("Validation Exception: ");
foreach (var error in validationException.ValidationErrors)
{
Console.WriteLine(" * Code: " + error.Code);