diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs index 31c60b1588..c5c27f857f 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs @@ -18,6 +18,7 @@ using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; using Volo.Abp.AspNetCore.MultiTenancy.Views; using Volo.Abp.AspNetCore.RazorViews; +using Volo.Abp.ExceptionHandling; using Volo.Abp.Http; using Volo.Abp.MultiTenancy; using Volo.Abp.Threading; @@ -76,7 +77,10 @@ public class AbpAspNetCoreMultiTenancyOptions } else if (context.Request.IsAjax()) { - var error = new RemoteServiceErrorResponse(new RemoteServiceErrorInfo(exception.Message, exception is BusinessException businessException ? businessException.Details : string.Empty)); + var error = new RemoteServiceErrorResponse(new RemoteServiceErrorInfo( + exception.Message, + exception is BusinessException businessException ? businessException.Details : string.Empty, + (exception as IHasErrorCode)?.Code)); var jsonSerializerOptions = context.RequestServices.GetRequiredService>().Value.SerializerOptions; diff --git a/framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancy_MultiTenancyMiddlewareErrorPageBuilder_Tests.cs b/framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancy_MultiTenancyMiddlewareErrorPageBuilder_Tests.cs index 2d2de48992..8f3b848a35 100644 --- a/framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancy_MultiTenancyMiddlewareErrorPageBuilder_Tests.cs +++ b/framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancy_MultiTenancyMiddlewareErrorPageBuilder_Tests.cs @@ -33,6 +33,7 @@ public class AspNetCoreMultiTenancy_MultiTenancyMiddlewareErrorPageBuilder_Tests var result = await response.Content.ReadAsStringAsync(); var error = JsonSerializer.Deserialize(result, new JsonSerializerOptions {PropertyNamingPolicy = JsonNamingPolicy.CamelCase}); error.Error.ShouldNotBeNull(); + error.Error.Code.ShouldBe("Volo.AbpIo.MultiTenancy:010001"); error.Error.Message.ShouldBe("Tenant not found!"); error.Error.Details.ShouldBe("There is no tenant with the tenant id or name: abpio"); }