From f88936aecccdbc056b9a143e97f22ce4968094cd Mon Sep 17 00:00:00 2001 From: xlogex <27079402+xlogex@users.noreply.github.com> Date: Fri, 14 Jan 2022 03:12:20 +0100 Subject: [PATCH] ApiHelper.ExecuteCallGuardedAsync cannot catch exception #81 --- src/Client/Shared/ApiHelper.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Client/Shared/ApiHelper.cs b/src/Client/Shared/ApiHelper.cs index f0f0b6c0..25c14d62 100644 --- a/src/Client/Shared/ApiHelper.cs +++ b/src/Client/Shared/ApiHelper.cs @@ -1,4 +1,5 @@ -using FSH.BlazorWebAssembly.Client.Infrastructure.ApiClient; +using System.Net; +using FSH.BlazorWebAssembly.Client.Infrastructure.ApiClient; using MudBlazor; namespace FSH.BlazorWebAssembly.Client.Shared; @@ -38,6 +39,13 @@ public static class ApiHelper { snackbar.Add(ex.Result.Exception, Severity.Error); } + catch (ApiException ex) + { + if (ex.StatusCode == (int)HttpStatusCode.Unauthorized) + { + snackbar.Add("Unauthorized!!!", Severity.Error); + } + } return default; }