From 8b526a517404dad4b17bdefc05e904d6a526b228 Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Thu, 12 Sep 2024 15:05:31 +0200 Subject: [PATCH] fix(environment): adjust getEnvironment exception handling (#89) Refs: #84 Reviewed-By: Evelyn Gurschler --- src/clients/Dim.Clients/Api/Cf/CfClient.cs | 4 ++-- src/clients/Dim.Clients/Api/Entitlements/EntitlementClient.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/clients/Dim.Clients/Api/Cf/CfClient.cs b/src/clients/Dim.Clients/Api/Cf/CfClient.cs index 1df819e..956bf51 100644 --- a/src/clients/Dim.Clients/Api/Cf/CfClient.cs +++ b/src/clients/Dim.Clients/Api/Cf/CfClient.cs @@ -80,9 +80,9 @@ private static async Task GetEnvironmentId(string tenantName, Cancellation .ConfigureAwait(false); var tenantEnvironment = environments?.Resources.Where(x => x.Name == tenantName); - if (tenantEnvironment == null || tenantEnvironment.Count() > 1) + if (tenantEnvironment == null || tenantEnvironment.Count() != 1) { - throw new ConflictException($"There should only be one cf environment for tenant {tenantName}"); + throw new ServiceException($"There should only be one cf environment for tenant {tenantName}", true); } return tenantEnvironment.Single().EnvironmentId; diff --git a/src/clients/Dim.Clients/Api/Entitlements/EntitlementClient.cs b/src/clients/Dim.Clients/Api/Entitlements/EntitlementClient.cs index 8103474..5b79bdd 100644 --- a/src/clients/Dim.Clients/Api/Entitlements/EntitlementClient.cs +++ b/src/clients/Dim.Clients/Api/Entitlements/EntitlementClient.cs @@ -48,6 +48,6 @@ public async Task AssignEntitlements(BasicAuthSettings basicAuthSettings, Guid s ); await client.PutAsJsonAsync("/entitlements/v1/subaccountServicePlans", data, JsonSerializerExtensions.Options, cancellationToken) - .CatchingIntoServiceExceptionFor("assign-entitlements", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE).ConfigureAwait(false); + .CatchingIntoServiceExceptionFor("assign-entitlements", HttpAsyncResponseMessageExtension.RecoverOptions.ALLWAYS).ConfigureAwait(false); } }