Browse Source

统一异常信息返回

pull/862/head
李宏 2 years ago
parent
commit
2b0600db4f
  1. 11
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessagesHub.cs
  2. 9
      aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Messages/SignalRMessageSenderProvider.cs
  3. 9
      aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN/Abp/OpenApi/Authorization/OpenApiAuthorizationService.cs
  4. 4
      aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs

11
aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessagesHub.cs

@ -41,6 +41,9 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
protected IUserGroupStore UserGroupStore => LazyServiceProvider.LazyGetRequiredService<IUserGroupStore>();
protected AbpExceptionHandlingOptions ExceptionHandlingOptions => LazyServiceProvider.LazyGetRequiredService<IOptions<AbpExceptionHandlingOptions>>().Value;
public override async Task OnConnectedAsync()
{
await base.OnConnectedAsync();
@ -167,8 +170,8 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
{
var errorInfo = ErrorInfoConverter.Convert(ex, options =>
{
options.SendExceptionsDetailsToClients = false;
options.SendStackTraceToClients = false;
options.SendExceptionsDetailsToClients = ExceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = ExceptionHandlingOptions.SendStackTraceToClients;
});
await SendMessageAsync(
@ -230,8 +233,8 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs
{
var errorInfo = ErrorInfoConverter.Convert(ex, options =>
{
options.SendExceptionsDetailsToClients = false;
options.SendStackTraceToClients = false;
options.SendExceptionsDetailsToClients = ExceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = ExceptionHandlingOptions.SendStackTraceToClients;
});
if (!chatMessage.GroupId.IsNullOrWhiteSpace())
{

9
aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Messages/SignalRMessageSenderProvider.cs

@ -19,14 +19,17 @@ namespace LINGYUN.Abp.IM.SignalR.Messages
private readonly AbpIMSignalROptions _options;
private readonly IHubContext<MessagesHub> _hubContext;
private readonly AbpExceptionHandlingOptions _exceptionHandlingOptions;
public SignalRMessageSenderProvider(
IHubContext<MessagesHub> hubContext,
IAbpLazyServiceProvider serviceProvider,
IOptions<AbpIMSignalROptions> options)
IOptions<AbpIMSignalROptions> options,
IOptions<AbpExceptionHandlingOptions> exceptionHandlingOptions)
: base(serviceProvider)
{
_options = options.Value;
_exceptionHandlingOptions = exceptionHandlingOptions.Value;
_hubContext = hubContext;
}
@ -99,8 +102,8 @@ namespace LINGYUN.Abp.IM.SignalR.Messages
{
var errorInfo = errorInfoConverter.Convert(ex, options =>
{
options.SendExceptionsDetailsToClients = false;
options.SendStackTraceToClients = false;
options.SendExceptionsDetailsToClients = _exceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = _exceptionHandlingOptions.SendStackTraceToClients;
});
if (!chatMessage.GroupId.IsNullOrWhiteSpace())
{

9
aspnet-core/modules/open-api/LINGYUN.Abp.OpenApi.Authorization/LINGYUN/Abp/OpenApi/Authorization/OpenApiAuthorizationService.cs

@ -26,17 +26,20 @@ namespace LINGYUN.Abp.OpenApi.Authorization
private readonly AbpOpenApiOptions _openApiOptions;
private readonly ICurrentClient _currentClient;
private readonly IWebClientInfoProvider _clientInfoProvider;
private readonly AbpExceptionHandlingOptions _exceptionHandlingOptions;
public OpenApiAuthorizationService(
IAppKeyStore appKeyStore,
ICurrentClient currentClient,
IWebClientInfoProvider clientInfoProvider,
IOptionsMonitor<AbpOpenApiOptions> options)
IOptionsMonitor<AbpOpenApiOptions> options,
IOptions<AbpExceptionHandlingOptions> exceptionHandlingOptions)
{
_appKeyStore = appKeyStore;
_currentClient = currentClient;
_clientInfoProvider = clientInfoProvider;
_openApiOptions = options.CurrentValue;
_exceptionHandlingOptions = exceptionHandlingOptions.Value;
}
public async virtual Task<bool> AuthorizeAsync(HttpContext httpContext)
@ -177,8 +180,8 @@ namespace LINGYUN.Abp.OpenApi.Authorization
var errorInfoConverter = context.RequestServices.GetRequiredService<IExceptionToErrorInfoConverter>();
var errorInfo = errorInfoConverter.Convert(exception, options =>
{
options.SendExceptionsDetailsToClients = false;
options.SendStackTraceToClients = false;
options.SendExceptionsDetailsToClients = _exceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = _exceptionHandlingOptions.SendStackTraceToClients;
});
if (context.Request.CanAccept(MimeTypes.Application.Json) ||

4
aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs

@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using StackExchange.Redis;
using System;
@ -166,7 +167,8 @@ public partial class PlatformManagementHttpApiHostModule
Configure<Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingOptions>(options =>
{
// 是否发送错误详情
options.SendExceptionsDetailsToClients = false;
options.SendExceptionsDetailsToClients = true;
options.SendStackTraceToClients = true;
});
}

Loading…
Cancel
Save