From cec2dc579ac43960755688483314de1ef1d09d1e Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Tue, 7 Apr 2020 16:22:43 +0300 Subject: [PATCH] throw business exception for tenant not found. closes #3500 --- .../MultiTenancy/MultiTenancyMiddleware.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs index ba8802a80e..2c82095dac 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs @@ -14,9 +14,9 @@ namespace Volo.Abp.AspNetCore.MultiTenancy private readonly ITenantResolveResultAccessor _tenantResolveResultAccessor; public MultiTenancyMiddleware( - ITenantResolver tenantResolver, - ITenantStore tenantStore, - ICurrentTenant currentTenant, + ITenantResolver tenantResolver, + ITenantStore tenantStore, + ICurrentTenant currentTenant, ITenantResolveResultAccessor tenantResolveResultAccessor) { _tenantResolver = tenantResolver; @@ -34,11 +34,13 @@ namespace Volo.Abp.AspNetCore.MultiTenancy if (resolveResult.TenantIdOrName != null) { tenant = await FindTenantAsync(resolveResult.TenantIdOrName); + if (tenant == null) { - //TODO: A better exception? - throw new AbpException( - "There is no tenant with given tenant id or name: " + resolveResult.TenantIdOrName + throw new BusinessException( + code: "Volo.AbpIo.MultiTenancy:010001", + message: "Tenant not found!", + details: "There is no tenant with the tenant id or name: " + resolveResult.TenantIdOrName ); } }