From 22d0311ec425da185c68845eff3a2f128906c44b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=96=C2=96AsTroLog?= Date: Wed, 22 Nov 2023 18:07:05 +0000 Subject: [PATCH] add error handling --- .../Pages/Chat.razor.cs | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/ShoppingAssistantWebClient.Web/Pages/Chat.razor.cs b/ShoppingAssistantWebClient.Web/Pages/Chat.razor.cs index 476cdd1..5e1f65a 100644 --- a/ShoppingAssistantWebClient.Web/Pages/Chat.razor.cs +++ b/ShoppingAssistantWebClient.Web/Pages/Chat.razor.cs @@ -38,39 +38,44 @@ public partial class Chat : ComponentBase private string name = ""; protected override async Task OnInitializedAsync() { - var input = _searchServise.firstMassage; + try{ + var input = _searchServise.firstMassage; - if (input!=null){ + if (input!=null){ - await LoadMessages(); + await LoadMessages(); - await AddNewMessage(input); + await AddNewMessage(input); + + string wishlistId = chatId; + var request = new GraphQLRequest + { + Query = @"mutation GenerateNameForPersonalWishlist($wishlistId: String!) { + generateNameForPersonalWishlist(wishlistId: $wishlistId) { + id + name + } + }", + Variables = new + { + wishlistId - string wishlistId = chatId; - var request = new GraphQLRequest - { - Query = @"mutation GenerateNameForPersonalWishlist($wishlistId: String!) { - generateNameForPersonalWishlist(wishlistId: $wishlistId) { - id - name } - }", - Variables = new - { - wishlistId + }; + var response = await _apiClient.QueryAsync(request); + _searchServise.SetFirstMassage(null); + isLoading = false; + await UpdateSideMenu(wishlistId); + StateHasChanged(); + + }else{ + await LoadMessages(); } - }; - - var response = await _apiClient.QueryAsync(request); - _searchServise.SetFirstMassage(null); - isLoading = false; - await UpdateSideMenu(wishlistId); - StateHasChanged(); - - }else{ - await LoadMessages(); + }catch(Exception ex){ + Console.WriteLine($"Error OnInitializedAsync: {ex.Message}"); } + }