From 6b954293ba50ba72176aae6d63dc66bf4e407f81 Mon Sep 17 00:00:00 2001 From: Julia Ilasova <1julka1il@gmail.com> Date: Tue, 28 May 2024 14:03:05 +0200 Subject: [PATCH] can we log errors? --- Tests/WebSocketTestClient.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Tests/WebSocketTestClient.cs b/Tests/WebSocketTestClient.cs index 65c9a44..b120184 100644 --- a/Tests/WebSocketTestClient.cs +++ b/Tests/WebSocketTestClient.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using api.Events.Global; using lib; using Websocket.Client; @@ -12,12 +13,20 @@ public class WebSocketTestClient public WebSocketTestClient(string? url = null) { Client = url == null ? new WebsocketClient(new Uri("ws://localhost:" + (Environment.GetEnvironmentVariable("FULLSTACK_API_PORT") ?? "8181"))) : new WebsocketClient(new Uri(url)); - Client.MessageReceived.Subscribe((Action) (msg => + Client.MessageReceived.Subscribe(msg => { BaseDto baseDto = JsonSerializer.Deserialize(msg.Text); + + if (baseDto.eventType == "ServerSendsError") + { + var error = JsonSerializer.Deserialize(msg.Text); + throw new Exception(error!.Error); + } + + lock (ReceivedMessages) ReceivedMessages.Add(baseDto); - })); + }); } public async Task ConnectAsync()