From 6bdee5dd34e9a1bd0643ccafd68e6c7c3553b257 Mon Sep 17 00:00:00 2001 From: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com> Date: Tue, 7 May 2024 17:45:01 +0100 Subject: [PATCH] Fix the issue of returning on Error! without descriptive message (#4056) Signed-off-by: Cy Okeke --- .../ProviderOrganizationsController.cs | 17 +++++++++++++---- .../_ProviderOrganizationScripts.cshtml | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Admin/AdminConsole/Controllers/ProviderOrganizationsController.cs b/src/Admin/AdminConsole/Controllers/ProviderOrganizationsController.cs index b2deede4a4..a017b2b435 100644 --- a/src/Admin/AdminConsole/Controllers/ProviderOrganizationsController.cs +++ b/src/Admin/AdminConsole/Controllers/ProviderOrganizationsController.cs @@ -3,6 +3,7 @@ using Bit.Admin.Utilities; using Bit.Core.AdminConsole.Providers.Interfaces; using Bit.Core.AdminConsole.Repositories; using Bit.Core.Billing.Commands; +using Bit.Core.Exceptions; using Bit.Core.Repositories; using Bit.Core.Utilities; using Microsoft.AspNetCore.Authorization; @@ -55,10 +56,18 @@ public class ProviderOrganizationsController : Controller return RedirectToAction("View", "Providers", new { id = providerId }); } - await _removeOrganizationFromProviderCommand.RemoveOrganizationFromProvider( - provider, - providerOrganization, - organization); + try + { + await _removeOrganizationFromProviderCommand.RemoveOrganizationFromProvider( + provider, + providerOrganization, + organization); + } + catch (BadRequestException ex) + { + return BadRequest(ex.Message); + } + await _removePaymentMethodCommand.RemovePaymentMethod(organization); diff --git a/src/Admin/AdminConsole/Views/Providers/_ProviderOrganizationScripts.cshtml b/src/Admin/AdminConsole/Views/Providers/_ProviderOrganizationScripts.cshtml index b8fefb4c14..9246243c61 100644 --- a/src/Admin/AdminConsole/Views/Providers/_ProviderOrganizationScripts.cshtml +++ b/src/Admin/AdminConsole/Views/Providers/_ProviderOrganizationScripts.cshtml @@ -12,7 +12,7 @@ window.location.href = `@Url.Action("Edit", "Providers")?id=${providerId}`; }, error: function (response) { - alert("Error!"); + alert("Error!: " + response.responseText); } }); }